Replies: 2 comments 1 reply
-
Use |
Beta Was this translation helpful? Give feedback.
0 replies
-
Thanks for this info. Unfortunately, it does not solve my problem because I posed the wrong question. The right question would have been: Then, I could avoid starting the thread at the first start and have it only started the second time. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Issue Description
I have a similar issue as #5307 and I also understand the arguments related to threads in web applications.
In my case of a web server for controlling Raspberry Pi cameras raspiCamSrv, there are several threads under control of the web app, like live stream, video recording, etc.
These threads use the Picamera2 library which starts its own threads.
This is normally not an issue because these threads are started by users from the Web UI after the Flask server has started.
Now, I have added a motion capture feature, which is also running in an own thread and users want this feature to be automatically started with the server, for example after the device has been rebooted.
Currently, I start this thread in the app factory
create_app()
.And, as in #5307, the thread is started again when I start Flask with the
--debug
option.I do not seem to have the possibility from my own code to detect whether these threads are already active.
The classes from which these threads are started and which hold their references, seem to be initialized again, although they are singletons.
Question
I am not considering this as a bug.
My question is whether there is a possibility in
create_app()
, to know that the app is being recreated on behalf of the autoloader.Environment:
Beta Was this translation helpful? Give feedback.
All reactions