diff --git a/simple_app.py b/simple_app.py index 24d25971..8a1d6be5 100644 --- a/simple_app.py +++ b/simple_app.py @@ -1,4 +1,5 @@ import uwsgi +import os print("!!! uWSGI version:", uwsgi.version) @@ -7,6 +8,7 @@ def ciao(): def ciao2(): print("nuovo uwsgi_server") + print os.getpid() counter = 0 @@ -19,6 +21,8 @@ counter = 0 #uwsgi.event_add(uwsgi.EVENT_DNSSD, "_uwsgi._tcp", ciao2) #uwsgi.event_add(uwsgi.EVENT_TIMER, 1000, ciao2) +uwsgi.post_fork_hook = ciao2 + def application(env, start_response): global counter diff --git a/uwsgi.c b/uwsgi.c index 60ceb72d..229e5dd4 100644 --- a/uwsgi.c +++ b/uwsgi.c @@ -1502,6 +1502,19 @@ int main(int argc, char *argv[], char *envp[]) { } } +#ifdef UWSGI_EMBEDDED + // call the post_fork_hook + PyObject *uwsgi_dict = get_uwsgi_pydict("uwsgi"); + if (uwsgi_dict) { + PyObject *pfh = PyDict_GetItemString(uwsgi_dict, "post_fork_hook"); + if (pfh) { + python_call(pfh, PyTuple_New(0), 0); + } + } + PyErr_Clear(); +#endif + + // postpone the queue initialization as kevent do not pass kfd after fork() #ifdef UWSGI_ASYNC