Author dripton
Recipients dripton
Date 2007-09-20.19:35:41
SpamBayes Score 0.0472304
Marked as misclassified No
Message-id <1190316942.33.0.242562253308.issue1183@psf.upfronthosting.co.za>
In-reply-to
Content
CentOS Linux 5, Python 2.4.3  (but code appears unchanged in 2.5 and
trunk, so I don't believe this bug has already been fixed)

We have an xmlrpc server that subclasses DocXMLRPCServer.DocXMLRPCServer
and SocketServer.ForkingMixIn.  Under load, it sometimes crashes with an
error in SocketServer.ForkingMixIn.collect_children

The bug is that collect_children calls os.waitpid with pid 0, so it
waits for any child.  But then it assumes that the pid found was in the
list self.active_children, and attempts to remove it from that list
without a try block.  However, another call to collect_children could
have already removed it, so we get "ValueError: list.remove(x): x not in
list"

The fix is just adding a try/except block around the attempt to remove
pid from self.active children.

diff -u SocketServer.py /tmp/SocketServer.py
--- SocketServer.py     2007-08-27 10:52:24.000000000 -0400
+++ /tmp/SocketServer.py        2007-09-20 15:34:00.000000000 -0400
@@ -421,7 +421,10 @@
             except os.error:
                 pid = None
             if not pid: break
-            self.active_children.remove(pid)
+            try:
+                self.active_children.remove(pid)
+            except ValueError:
+                pass

     def process_request(self, request, client_address):
         """Fork a new subprocess to process the request."""
History
Date User Action Args
2007-09-20 19:35:42driptonsetspambayes_score: 0.0472304 -> 0.0472304
recipients: + dripton
2007-09-20 19:35:42driptonsetspambayes_score: 0.0472304 -> 0.0472304
messageid: <1190316942.33.0.242562253308.issue1183@psf.upfronthosting.co.za>
2007-09-20 19:35:42driptonlinkissue1183 messages
2007-09-20 19:35:41driptoncreate