Rev 5274: Factor out socket exception handling during server shutdown. in file:///home/vila/src/bzr/experimental/leaking-tests/
v.ladeuil+lp at free.fr
Mon Jun 7 15:25:20 BST 2010
revision-id: v.ladeuil+lp at free.fr-20100607142519-d37kawz1w1btjym3
parent: v.ladeuil+lp at free.fr-20100607140519-b4jdekuz1ln9ocy8
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: propagate-exceptions
timestamp: Mon 2010-06-07 16:25:19 +0200
Factor out socket exception handling during server shutdown.
out the exceptions that can occur during server shutdown. This
should be used both for the server and client connections threads
as well as the main thread itself (since the socket exception can
be raised in any thread, at least on windows).
(TestingTCPServerInAThread.stop_server): Install the exception handler.
-------------- next part --------------
=== modified file 'bzrlib/tests/test_server.py'
--- a/bzrlib/tests/test_server.py 2010-06-07 14:05:19 +0000
+++ b/bzrlib/tests/test_server.py 2010-06-07 14:25:19 +0000
@@ -372,6 +372,16 @@
+ def ignored_exceptions_during_shutdown(self, e):
+ if sys.platform == 'win32':
+ accepted_errnos = [errno.WSAEBADF, errno.WSAENOTCONN,
+ accepted_errnos = [errno.EBADF, errno.ENOTCONN, errno.ECONNRESET]
+ if isinstance(e, socket.error) and e in accepted_errnos:
+ return True
+ return False
# The following methods are called by the main thread
@@ -389,18 +399,13 @@
This should be called only when no other thread is trying to use the
+ # The request process has been completed, the thread is about to
+ # die, let's shutdown the socket if we can.
- # The request process has been completed, the thread is about to
- # die, let's shutdown the socket if we can.
- except (socket.error, select.error), e:
- accepted_errnos = [errno.EBADF, errno.ENOTCONN, errno.ECONNRESET]
- if sys.platform == 'win32':
- accepted_errnos.extend([errno.WSAEBADF, errno.WSAENOTCONN,
- if e in accepted_errnos:
- # Right, the socket is already down
+ except Exception, e:
+ if self.ignored_exceptions(e):
@@ -550,9 +555,10 @@
# The server has been started successfully, shut it down now. As
- # soon as we stop serving, no more connection are accepted except
- # one to get out of the blocking listen.
+ # soon as we stop serving, no more connection are accepted.
# The server is listening for a last connection, let's give it:
last_conn = None
More information about the bazaar-commits