ForkingServer hang #15

Closed
tomerfiliba opened this Issue Mar 2, 2011 · 1 comment

Projects

None yet

1 participant

@tomerfiliba
Owner

mman Show activity 3/1/10
Hello all,
I'm using the ForkingServer and I have noticed that the server-side
hangs
when a client disconnects. Looking through the code I found that the
SIGCHLD
handler inside the ForkingServer class needs some checks. Below is a
patch
that fixes the problem. Tomer, feel free to include this in the rpyc
distribution.
I'm using python 2.6.4 here.


diff -ur rpyc-3.0.7-py2.6/utils/server.py rpyc-3.0.7-py2.6.my/utils/
server.py
--- rpyc-3.0.7-py2.6/utils/server.py    2009-09-22 14:38:28.000000000
+0300
+++ rpyc-3.0.7-py2.6.my/utils/server.py 2010-03-01 12:44:36.000000000
+0200
@@ -202,11 +202,15 @@
     def _handle_sigchld(signum, unused):
         try:
             while True:
-                os.waitpid(-1, os.WNOHANG)
+                r = os.waitpid(-1, os.WNOHANG)
+                print "waitpid returned %s" % repr(r)
+                if r == (0, 0):
+                    time.sleep(1)
+                else:
+                    print "our child %d terminated" % r[0]
+                    break
         except OSError:
             pass
-        # re-register signal handler (see man signal(2), under
Portability)
-        signal.signal(signal.SIGCHLD, self._handle_sigchld)

     def _accept_method(self, sock):
         pid = os.fork()
@tomerfiliba
Owner

fixes a28b882; closed by 7eb48a4; closed by 7eb48a4; closed by 7eb48a4; closed by 7eb48a4; closed by 7eb48a4; closed by 7eb48a4;

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment