Python multiprocessing and how to wrap up and successfully exit

I’m learning python as I go and am currently implementing multiprocessing but I cannot successfully exit the app I’ve written. It seems the ‘capture_read_frame_process’ process just doesn’t end and I cannot see why. Any pointers here would be appreicated.

import cv2 as cv
import multiprocessing

class Camera(object):
    def __init__(self, source):
        self._source = source
        self.image_queue = multiprocessing.Queue()

        match self._source:
            case 'cam':
                self._source_url = 0
                self._apiPref = cv.CAP_DSHOW
            case 'boysr':
                self._source_url = 'rtsps://192.168.1.1:7441/xhw7D6R7BR8NP5vg'
                self._apiPref = cv.CAP_FFMPEG
            case 'frontd':   
                self._source_url = 'rtsps://192.168.1.1:7441/EOEohGh0eoXIWf28'
                self._apiPref = cv.CAP_FFMPEG
            case 'video':
                self._source_url = 'event.mp4'
                self._apiPref = cv.CAP_FFMPEG
    
    def read_frames(self, queue, stop_read):
        self.query_source = cv.VideoCapture(self._source_url, self._apiPref)
        self.query_source.set(cv.CAP_PROP_BUFFERSIZE, 1)
        self.query_source.set(cv.CAP_PROP_FPS, 20)

        if self.query_source.isOpened():
            print('Capture object successfully started')
        else:
            raise Exception('Unable to start capture object')

        _failFrame = 0
        while not stop_read.is_set():
            _hasFrame, _query_image = self.query_source.read()
            if not _hasFrame:
                _failFrame += 1
                if _failFrame == 15:
                    raise Exception(f"Failed to grab a frame after {_failFrame} consequtive tries")
                continue
            else:
                _failFrame = 0
                queue.put(_query_image)

        self.query_source.release()

    def show_frame(self, queue, stop_read):
        while True:
            _query_image = queue.get()
            cv.imshow('autoface', _query_image)
            if cv.waitKey(1) == ord('q'):
                cv.destroyAllWindows()
                break

if __name__ == '__main__':
    print('Starting capture object')
    capture = Camera('cam')

    # Create the event to use to stop the program
    stop_read = multiprocessing.Event()

    print('Starting read_frames process')
    capture_read_frame_process = multiprocessing.Process(target=capture.read_frames, args=(capture.image_queue, stop_read,))
    capture_read_frame_process.start()
    
    print('Starting show_frames process')
    capture_show_frame_process = multiprocessing.Process(target=capture.show_frame, args=(capture.image_queue, stop_read,))
    capture_show_frame_process.start()

    capture_show_frame_process.join()   # Should complete when 'q' is typed when the cv.imshow window is open and active.

    stop_read.set()     # This should then break the loop in the read_frames function of the Camera object
    
    capture_read_frame_process.join()
    
    print('nProgram exited')

When the image is displayed on screen pressing ‘q’ should close the window and cause the program to exit. It does close the window but the code never gets past the ‘capture_read_frame_process.join()’ statement.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật