Rev 5297: Better explain ThreadWithException.set_ready_event and why it's needed. in file:///home/vila/src/bzr/experimental/leaking-tests/
Vincent Ladeuil
v.ladeuil+lp at free.fr
Wed Jun 30 16:35:52 BST 2010
At file:///home/vila/src/bzr/experimental/leaking-tests/
------------------------------------------------------------
revno: 5297
revision-id: v.ladeuil+lp at free.fr-20100630153551-o00o5olc08l4hfin
parent: v.ladeuil+lp at free.fr-20100630151936-bwh082le0i52p8ez
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: propagate-exceptions
timestamp: Wed 2010-06-30 17:35:51 +0200
message:
Better explain ThreadWithException.set_ready_event and why it's needed.
-------------- next part --------------
=== modified file 'bzrlib/tests/test_server.py'
--- a/bzrlib/tests/test_server.py 2010-06-30 15:19:36 +0000
+++ b/bzrlib/tests/test_server.py 2010-06-30 15:35:51 +0000
@@ -258,7 +258,7 @@
# If the caller didn't pass a specific event, create our own
event = threading.Event()
super(ThreadWithException, self).__init__(*args, **kwargs)
- self.set_event(event)
+ self.set_ready_event(event)
self.exception = None
self.ignored_exceptions = None # see set_ignored_exceptions
@@ -266,7 +266,17 @@
if sys.version_info < (2, 6):
name = property(threading.Thread.getName, threading.Thread.setName)
- def set_event(self, event):
+ def set_ready_event(self, event):
+ """Set the ``ready`` event used to synchronize exception catching.
+
+ When the thread uses an event to synchronize itself with another thread
+ (setting it when the other thread can wake up from a ``wait`` call),
+ the event must be set after catching an exception or the other thread
+ will hang.
+
+ Some threads require multiple events and should set the relevant one
+ when appropriate.
+ """
self.ready = event
def set_ignored_exceptions(self, ignored):
@@ -576,7 +586,7 @@
self._server_thread.pending_exception()
# From now on, we'll use a different event to ensure the server can set
# its exception
- self._server_thread.set_event(self.server.stopped)
+ self._server_thread.set_ready_event(self.server.stopped)
def run_server(self):
self.server.serve()
=== modified file 'bzrlib/tests/test_test_server.py'
--- a/bzrlib/tests/test_test_server.py 2010-06-23 15:30:04 +0000
+++ b/bzrlib/tests/test_test_server.py 2010-06-30 15:35:51 +0000
@@ -223,7 +223,7 @@
def handle_connection(self):
req = self.rfile.readline()
- threading.currentThread().set_event(sync)
+ threading.currentThread().set_ready_event(sync)
raise FailToRespond()
server = self.get_server(
@@ -245,7 +245,7 @@
def handle(self):
# We want to sync with the thread that is serving the
# connection.
- threading.currentThread().set_event(sync)
+ threading.currentThread().set_ready_event(sync)
raise CantServe()
server = self.get_server(
More information about the bazaar-commits
mailing list