]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Andy Dustman writes:
authorGuido van Rossum <guido@python.org>
Fri, 21 May 1999 16:12:30 +0000 (16:12 +0000)
committerGuido van Rossum <guido@python.org>
Fri, 21 May 1999 16:12:30 +0000 (16:12 +0000)
I noticed while watching (with lsof) my forking SocketServer app running
that I would get multiple processes listening to the socket. For the most
part, this doesn't hurt things, but if you terminate the server, this can
prevent it from restarting because it cannot bind to the port due to any
running children which also have the socket open. The following one-liner
fixes this.

Lib/SocketServer.py

index 23f3a8e8be34fe508c867dd790613fdf519b4982..d8081efbe0154de41b72564ac1a3b0f2f0ee0a11 100644 (file)
@@ -304,6 +304,7 @@ class ForkingMixIn:
                 os._exit(0)
             except:
                 try:
+                    self.socket.close()
                     self.handle_error(request,
                                       client_address)
                 finally: