diff options
author | Peter Åstrand (astrand) <astrand@cendio.se> | 2013-11-28 09:07:41 +0100 |
---|---|---|
committer | Peter Åstrand (astrand) <astrand@cendio.se> | 2013-11-28 09:07:41 +0100 |
commit | 972b30ddc222c9cfe3899f5eef679c85eacb085d (patch) | |
tree | 238fb0518b7e7f8633ed4eaf5c4cf5a96bf773d1 | |
parent | f58b49fa084e85400dbff0c5de249c014543c507 (diff) | |
parent | 0e5c3ecfda3b1506b41412052db75d84df2b4ae7 (diff) | |
download | websockify-972b30ddc222c9cfe3899f5eef679c85eacb085d.tar.gz |
Merge commit '0e5c3ecfda3b1506b41412052db75d84df2b4ae7'
* commit '0e5c3ecfda3b1506b41412052db75d84df2b4ae7':
Handle SIGCHLD properly for multiprocessing
-rw-r--r-- | websockify/websocket.py | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/websockify/websocket.py b/websockify/websocket.py index 11ea9e6..a2c6e64 100644 --- a/websockify/websocket.py +++ b/websockify/websocket.py @@ -815,6 +815,9 @@ class WebSocketServer(object): def terminate(self): raise self.Terminate() + def multiprocessing_SIGCHLD(self, sig, stack): + self.vmsg('Reaing zombies, active child count is %s', len(multiprocessing.active_children())) + def fallback_SIGCHLD(self, sig, stack): # Reap zombies when using os.fork() (python 2.4) self.vmsg("Got SIGCHLD, reaping zombies") @@ -881,7 +884,13 @@ class WebSocketServer(object): } signal.signal(signal.SIGINT, self.do_SIGINT) signal.signal(signal.SIGTERM, self.do_SIGTERM) - signal.signal(signal.SIGCHLD, self.fallback_SIGCHLD) + if not multiprocessing: + # os.fork() (python 2.4) child reaper + signal.signal(signal.SIGCHLD, self.fallback_SIGCHLD) + else: + # make sure that _cleanup is called when children die + # by calling active_children on SIGCHLD + signal.signal(signal.SIGCHLD, self.multiprocessing_SIGCHLD) last_active_time = self.launch_time try: |