I'm new to multiprocessing but have spent a whole day trying to get the following to work properly.
I'm trying to run my Webcam using OpenCV (func_run_forever) in parallel with a single requests.get (func_run_once). So the expected result is my webcam running in a window (imshow), and a single Response 200 from requests.get while my webcam is running. However, the request.get won't run until I quit the OpenCV window.
Any help, tips, clues...or even answers would be much appreciated!
from multiprocessing import Process
import cv2
import requestsdef func_run_forever():cap = cv2.VideoCapture(0)while(True):ret, frame = cap.read()cv2.imshow('frame',frame)if cv2.waitKey(1) & 0xFF == ord('q'):breakcap.release()cv2.destroyAllWindows()def func_run_once():res = requests.get('https://www.google.com.au')print(res)if __name__ == '__main__':p1 = Process(target=func_run_forever())p2 = Process(target=func_run_once())p1.start()p2.start()p1.join()p2.join()