Your additional threads must be initiated from the same application that is called by the WSGI server.
The following example creates a background thread that runs every 5 seconds and manages the data structures that are also available for routed Flask functions.
import threading import atexit from flask import Flask POOL_TIME = 5
Call it from Gunicorn with something like this:
gunicorn -b 0.0.0.0:5000 --log-config log.conf --pid=app.pid myfile:app
caio Apr 06 '14 at 21:27 2014-04-06 21:27
source share