Running multiple script at the same time - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Running multiple script at the same time (/thread-23015.html) |
Running multiple script at the same time - LoganSulpizio - Dec-07-2019 Hello, I'm new with Python and I'm trying to learn it. I would like to know how can I start/run several python scrip at the same time. I'm not familiar with it, do you have any good references where I could learn that? More details: For now I have two scripts (others may be added): 1: A script that takes some specific frames in a video stream and save them in a folder 2: A script that takes the frames of the folder (when he starts to be filled by script 1) and processes it. Both script need to run "forever" with a loop (for now, I'm using 'While(True):' on both) How could I run them simultaneously, in a way that they don't enter in conflict or interrupt each other, and which way should I use for me to be able to stop easily the 2 forever loop if needed? Thank you RE: Running multiple script at the same time - Clunk_Head - Dec-07-2019 You can use threading. Place both scripts in the same folder and write a third script. In this third script import the other two, lets call them capture and process and assume that they both have a main function. If they don't have a main function or you have problems making this work, consider posting your code. from threading import Thread import capture import process capturer = Thread(target=capture.main, daemon=True) capturer.start() processor = Thread(target=process.main, daemon=True) processor.start()This will start both scripts as individual processes. The will run even if you close the console that launched them. |