0

I am using Flask to take video from a camera and stream it so that I can view it in a browser. That is its only purpose.

I have another Python application that is controlling some hardware in a very tight loop. It analyzes feedback from the hardware and creates a report.

What I need is to know how to start and run both of these 'applications' in parallel and share data between them.

The hardware 'report' is then being overlayed on the video stream at particular update intervals.

How it is now:

flask.py
    |------ hardware.py

I would like to have:

main.py (intialization)-------- flask.py
                          |---- hardware.py

I have seen a few similar questions and responses but I am not sure that they apply to my case directly. E.g: Running a Flask server parallel to main app This application seems to have both applications threaded but in one file.

Here is another example: Can I have Python code to continue executing after I call Flask app.run? But, again, initialized in the same file as the rest of the Flask routes...

pmankow
  • 1
  • 1
  • Could they be two separate processes that share a database? `hardware.py` would write to the database and `flask.py` would read from the database (and the camera). It's possible they could just share a data file, but a database would probably be the better way. – Travis Aug 12 '20 at 03:31
  • So, perhaps a bash script that calls: python script1.py & python script2.py & – pmankow Aug 12 '20 at 03:44

0 Answers0