Reputation: 178
I have a flask app which I want to use with a while loop running in the background. My first thought was to use threading to run them at the same time. The problem I stumbled upon is that only the first thread works (whether the flask app or the function with while loop comes first). My code is:
from multiprocessing import Process
if __name__ == '__main__':
Process(target = app.run(host='0.0.0.0', port=8080)).start()
Process(target = statupdate()).start()
Note: I also used the library "thread" and making the flask app its own function.
Is there some way to fix this error or run the two simultaneously?
Upvotes: 1
Views: 2199
Reputation: 26900
You have a couple of issues:
In order to make this work, don't run the function:
Process(target=app.run, kwargs=dict(host='0.0.0.0', port=8080)).start()
Process(target=statupdate).start()
Upvotes: 2