-
Notifications
You must be signed in to change notification settings - Fork 967
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create a uWSGI postfork function registry. Also, start the tool conf
watcher thread post-fork.
- Loading branch information
Showing
10 changed files
with
46 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
""" | ||
Handle postfork functions under uWSGI | ||
""" | ||
|
||
# The uwsgi module is automatically injected by the parent uwsgi | ||
# process and only exists that way. If anything works, this is a | ||
# uwsgi-managed process. | ||
try: | ||
import uwsgi | ||
from uwsgidecorators import postfork | ||
if uwsgi.numproc: | ||
process_is_uwsgi = True | ||
except ImportError: | ||
# This is not a uwsgi process, or something went horribly wrong. | ||
process_is_uwsgi = False | ||
|
||
def pf_dec(func): | ||
return func | ||
postfork = pf_dec | ||
|
||
|
||
postfork_functions = [] | ||
|
||
|
||
@postfork | ||
def do_postfork(): | ||
for f, args, kwargs in [ t for t in postfork_functions ]: | ||
f(*args, **kwargs) | ||
|
||
|
||
def register_postfork_function(f, *args, **kwargs): | ||
if process_is_uwsgi: | ||
postfork_functions.append((f, args, kwargs)) | ||
else: | ||
f(*args, **kwargs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters