mirror of
https://github.com/clearlinux/uwsgi.git
synced 2026-09-06 13:41:28 +00:00
uwsgi.post_fork_hook
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user