~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_server.py

  • Committer: Vincent Ladeuil
  • Date: 2010-06-30 15:35:51 UTC
  • mto: (5247.6.7 http-leaks)
  • mto: This revision was merged to the branch mainline in revision 5396.
  • Revision ID: v.ladeuil+lp@free.fr-20100630153551-o00o5olc08l4hfin
Better explain ThreadWithException.set_ready_event and why it's needed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
258
258
            # If the caller didn't pass a specific event, create our own
259
259
            event = threading.Event()
260
260
        super(ThreadWithException, self).__init__(*args, **kwargs)
261
 
        self.set_event(event)
 
261
        self.set_ready_event(event)
262
262
        self.exception = None
263
263
        self.ignored_exceptions = None # see set_ignored_exceptions
264
264
 
266
266
    if sys.version_info < (2, 6):
267
267
        name = property(threading.Thread.getName, threading.Thread.setName)
268
268
 
269
 
    def set_event(self, event):
 
269
    def set_ready_event(self, event):
 
270
        """Set the ``ready`` event used to synchronize exception catching.
 
271
 
 
272
        When the thread uses an event to synchronize itself with another thread
 
273
        (setting it when the other thread can wake up from a ``wait`` call),
 
274
        the event must be set after catching an exception or the other thread
 
275
        will hang.
 
276
 
 
277
        Some threads require multiple events and should set the relevant one
 
278
        when appropriate.
 
279
        """
270
280
        self.ready = event
271
281
 
272
282
    def set_ignored_exceptions(self, ignored):
576
586
        self._server_thread.pending_exception()
577
587
        # From now on, we'll use a different event to ensure the server can set
578
588
        # its exception
579
 
        self._server_thread.set_event(self.server.stopped)
 
589
        self._server_thread.set_ready_event(self.server.stopped)
580
590
 
581
591
    def run_server(self):
582
592
        self.server.serve()