My program is designed in the following way:
- First part of the program takes real time values from a sensor and plots it using Matplotlib. This has to be done for long durations. And also, it logs information into a database.
- The second part is the IP Camera. I have to get the input from an IP Camera and display it. For displaying I am using OpenCV's
imshow
method. Also, I am storing the video from the IP Camera.
Question: I have the algorithms in place, the problem is I need to run both these in a while loops. The condition is that I cannot exit from any of them. Now threading is a good alternative for this but I have read about the GIL, so how do I go about running two infinite loops?
from multiprocessing import Process
def methodA():
while TRUE:
do something
def methodB():
while TRUE:
do something
p=Process(target=methodA())
p.start()
p1=Process(target=methodB())
p1.start()
Now when I start process p
it starts executing, after that how do I start p1
to run simultaneously?