Forum in maintenance, we will back soon 🙂
A cautionary tale about using Flask in debug mode with Python Threads
Let me just say I did hours of "debugging" just to find that if you use Flask in debug mode and are using Python Threads, the threads execute at least twice and sometimes 3 times.
I was creating a queue for email being sent to allow for one process to be sending the email and I was usually getting 2 but sometimes 1 and sometimes 3. I finally found the correct research query to determine that the issue was FLASK_DEBUG=true isn't compatible with running threads in an asynchronous manner. It didn't matter what I did to try to avoid the problem, there was always the potential for multiple emails.
Just wanted to share here so you can avoid wasted hours on trying to "debug" a problem in the code.
Regards,
Earnie Boyd, CEO
Seasoned Solutions Advisor LLC
Schedule 1-on-1 help
Join me on Slack
Thanks for sharing, but did you find out why?
Why would the debug mode fire threads this way? How, then, are we supposed to debug a multi-threaded app?
@admin not really other than some comment about debug mode starting 2 processes for some reason. It said something about needing that to monitor the changes in code.🤷
Regards,
Earnie Boyd, CEO
Seasoned Solutions Advisor LLC
Schedule 1-on-1 help
Join me on Slack
-
How to add payment using "Streamlit UI"
4 months ago
-
Localhost Information Script
10 months ago
-
How can i remember python scripting
10 months ago
-
I don't understand the reason of error.
1 year ago
-
csv download is not including all the results in a django application
1 year ago