mirror of
https://github.com/clearlinux/uwsgi.git
synced 2026-08-29 02:05:38 +00:00
added @postfork decorator
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import uwsgi
|
||||
|
||||
from uwsgidecorators import *
|
||||
|
||||
from uwsgicc import app as application
|
||||
@@ -52,5 +54,13 @@ def one_hour_passed(num):
|
||||
print("received signal %d after 1 hour" % num)
|
||||
|
||||
|
||||
@postfork
|
||||
def fork_happened():
|
||||
print("fork() has been called [1]")
|
||||
|
||||
@postfork
|
||||
def fork_happened2():
|
||||
print("fork() has been called [2] wid: %d" % uwsgi.worker_id())
|
||||
|
||||
a_long_task.spool({'foo':'bar'}, hello='world')
|
||||
an_infinite_task.spool(foo='bar')
|
||||
|
||||
+10
-1
@@ -7,6 +7,7 @@ if uwsgi.opt.get('lazy'):
|
||||
raise Exception("uWSGI lazy mode is not supporte by this module")
|
||||
|
||||
spooler_functions = {}
|
||||
postfork_chain = []
|
||||
|
||||
def get_free_signal():
|
||||
for signum in xrange(0, 256):
|
||||
@@ -21,8 +22,16 @@ def manage_spool_request(vars):
|
||||
return ret
|
||||
return spooler_functions[vars['ud_spool_func']].ret
|
||||
|
||||
uwsgi.spooler = manage_spool_request
|
||||
def postfork_chain_hook():
|
||||
for f in postfork_chain:
|
||||
f()
|
||||
|
||||
uwsgi.spooler = manage_spool_request
|
||||
uwsgi.post_fork_hook = postfork_chain_hook
|
||||
|
||||
class postfork(object):
|
||||
def __init__(self, f):
|
||||
postfork_chain.append(f)
|
||||
|
||||
class spool(object):
|
||||
|
||||
|
||||
Reference in New Issue
Block a user