Http://lists.unbit.it/pipermail/uwsgi/2012-April/004089.html
> I have a Web application written in flask. At startup it spawns a > Background thread and waits on a threading. Event for the background thread > to initialise before continuing. It works fine when run outside Uwsgi, but > then run in Uwsgi it hangs on the lock. I know the lock has been released > because I am writing to the "Log on" line before and "after the" > line
The code that releases the lock. > > This is me config file, I am running Uwsgi in Emperor mode: > > [UWSGI] > Master = true > Processes = 1 > Uid=edpod > Gid=edpod > virtualenv =/host/sites/edpod > Pythonpath =/host/sites/edpod > module = Ed Pod.uwsgi > callable = app > socket = 127.0.0.1:6000 > Enable-threads > > Does anyone have any ideas or can
Point me to some documentation around > I > Threading works in Uwsgi.
> Hi Richard, it is not a threading problem, but a fork ()-related one. I Suppose you are starting your thread in the APplication entry point (the file edpod/uwsgi.py).
The master would spawn the thread and then it fork ().
In the new process, the thread are no more.
The best way to solve it's in starting the thread of the fork (), using the Uwsgi.post_fork_hook. Another solution is in putting your stack in "lazy" mode. That means your The app is completely the loaded only for each fork (). Simply Add lazy = true for that setup.