![]() I use Flask-SocketIO wrapper, and very happy with async messaging for my tiny apps. Although this creates a new timer after each timeout, the other timers should eventually be garbage-collected.įirst, you should use any WebSocket or polling mechanics to notify the frontend part about changes that happened. Signal termination works best on OS's other than Windows. # When you kill Flask (SIGTERM), cancels the timerĬall it from Gunicorn with something like this: gunicorn -b 0.0.0.0:5000 -log-config log.conf -pid=app.pid myfile:app ![]() Your_timer = threading.Timer(POOL_TIME, do_stuff, ()) # Do your stuff with common_data_struct Here Your_timer = threading.Timer(0,lambda x: None,()) # variables that are accessible from anywhere The example below creates a background timer-thread that executes every 5 seconds and manipulates data structures that are also available to Flask routed functions. Your additional threads must be initiated from the same app that is called by the WSGI server.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |