~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-12 11:29:34 UTC
  • mto: (5247.6.1 http-leaks)
  • mto: This revision was merged to the branch mainline in revision 5396.
  • Revision ID: v.ladeuil+lp@free.fr-20100612112934-49gyqx2q818ok2i4
Compatibility with python 2.5 and 2.4 for ThreadWithException.name.

* bzrlib/tests/test_server.py:
(ThreadWithException.name): Define as a property to ensure
compatibility with previous python versions.
(TestingTCPServerInAThread.start_server): Wait for the server to
start so be able to name it after its resolved (host, port).

Show diffs side-by-side

added added

removed removed

Lines of Context:
262
262
        self.exception = None
263
263
        self.ignored_exceptions = None # see set_ignored_exceptions
264
264
 
 
265
    # compatibility thunk for python-2.4 and python-2.5...
 
266
    name = property(threading.Thread.getName, threading.Thread.setName)
 
267
 
265
268
    def set_event(self, event):
266
269
        self.ready = event
267
270
 
557
560
        self.server = self.create_server()
558
561
        self._server_thread = ThreadWithException(
559
562
            event=self.server.started,
560
 
            name=self.server_address,
561
563
            target=self.run_server)
562
564
        self._server_thread.start()
563
565
        # Wait for the server thread to start (i.e release the lock)
564
566
        self.server.started.wait()
565
 
        if debug_threads():
566
 
            print 'Server thread %s started' % (self._server_thread.name,)
567
567
        # Get the real address, especially the port
568
568
        self.server_address = self.server.server_address
 
569
        self._server_thread.name = self.server.server_address
 
570
        if debug_threads():
 
571
            print 'Server thread %s started' % (self._server_thread.name,)
569
572
        # If an exception occured during the server start, it will get raised,
570
573
        # otherwise, the server is blocked on its accept() call.
571
574
        self._server_thread.pending_exception()