diff options
-rwxr-xr-x | other/websockify.rb | 4 | ||||
-rwxr-xr-x | tests/echo.py | 4 | ||||
-rwxr-xr-x | tests/load.py | 4 | ||||
-rwxr-xr-x | tests/utf8-list.py | 5 | ||||
-rw-r--r-- | websockify/websocket.py | 11 |
5 files changed, 18 insertions, 10 deletions
diff --git a/other/websockify.rb b/other/websockify.rb index bdc61f1..d6310f3 100755 --- a/other/websockify.rb +++ b/other/websockify.rb @@ -92,7 +92,7 @@ Traffic Legend: # Receive target data and queue for the client if ins && ins.include?(target) buf = target.recv(@@Buffer_size) - if buf.length == 0: + if buf.length == 0 raise EClose, "Target closed" end @@ -128,7 +128,7 @@ parser = OptionParser.new do |o| o.parse! end -if ARGV.length < 2: +if ARGV.length < 2 puts "Too few arguments" exit 2 end diff --git a/tests/echo.py b/tests/echo.py index d79553e..1d46d50 100755 --- a/tests/echo.py +++ b/tests/echo.py @@ -11,8 +11,8 @@ as taken from http://docs.python.org/dev/library/ssl.html#certificates ''' import os, sys, select, optparse -sys.path.insert(0,os.path.dirname(__file__) + "/../websockify") -from websocket import WebSocketServer +sys.path.insert(0,os.path.join(os.path.dirname(__file__), "..")) +from websockify.websocket import WebSocketServer class WebSocketEcho(WebSocketServer): """ diff --git a/tests/load.py b/tests/load.py index 0da7265..e1354c9 100755 --- a/tests/load.py +++ b/tests/load.py @@ -7,8 +7,8 @@ given a sequence number. Any errors are reported and counted. ''' import sys, os, select, random, time, optparse -sys.path.insert(0,os.path.dirname(__file__) + "/../websockify") -from websocket import WebSocketServer +sys.path.insert(0,os.path.join(os.path.dirname(__file__), "..")) +from websockify.websocket import WebSocketServer class WebSocketLoad(WebSocketServer): diff --git a/tests/utf8-list.py b/tests/utf8-list.py index 60a8ae7..77bd430 100755 --- a/tests/utf8-list.py +++ b/tests/utf8-list.py @@ -5,9 +5,8 @@ Display UTF-8 encoding for 0-255.''' import sys, os, socket, ssl, time, traceback from select import select - -sys.path.insert(0,os.path.dirname(__file__) + "/../websockify") -from websocket import WebSocketServer +sys.path.insert(0,os.path.join(os.path.dirname(__file__), "..")) +from websockify.websocket import WebSocketServer if __name__ == '__main__': print "val: hybi_base64 | hybi_binary" diff --git a/websockify/websocket.py b/websockify/websocket.py index 14d1422..57b6b8d 100644 --- a/websockify/websocket.py +++ b/websockify/websocket.py @@ -718,6 +718,9 @@ Sec-WebSocket-Accept: %s\r 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") @@ -823,7 +826,13 @@ Sec-WebSocket-Accept: %s\r } 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: |