uwsgi.post_fork_hook

This commit is contained in:
roberto@mrspurr
2010-10-13 07:17:00 +02:00
parent 4b92ba5cbe
commit 441fb06129
2 changed files with 17 additions and 0 deletions
+4
View File
@@ -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
+13
View File
@@ -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