I am working on motion detection application in Raspberry Pi. There is a python script which should check output of c++
code and if "alert" is printed, it should start to upload images from a given directory to server:
for line in self.output:
if line == "alert\n":
# upload a frame from directory to a server
However, each frame takes around 30 seconds to upload to a server, but each new line is printed out in 500ms. So, it is not efficient at all to wait for uploading current frame in each if
condition of for
loop.
I am new to Python. Is there any way to run two methods parallel? I know about threads, but I am not sure what would happen if for
loop creates new thread each time in Raspberry Pi.