~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_server.py

  • Committer: Florent Gallaire
  • Date: 2017-03-17 10:39:02 UTC
  • mto: This revision was merged to the branch mainline in revision 6622.
  • Revision ID: fgallaire@gmail.com-20170317103902-xsmafws9vn8rczx9
Fix for Windows and 32-bit platforms buggy gmtime().

Show diffs side-by-side

added added

removed removed

Lines of Context:
432
432
    def get_request(self):
433
433
        """Get the request and client address from the socket."""
434
434
        sock, addr = TestingTCPServerMixin.get_request(self)
435
 
        # The thread is not create yet, it will be updated in process_request
 
435
        # The thread is not created yet, it will be updated in process_request
436
436
        self.clients.append((sock, addr, None))
437
437
        return sock, addr
438
438
 
439
 
    def process_request_thread(self, started, stopped, request, client_address):
 
439
    def process_request_thread(self, started, detached, stopped,
 
440
                               request, client_address):
440
441
        started.set()
 
442
        # We will be on our own once the server tells us we're detached
 
443
        detached.wait()
441
444
        SocketServer.ThreadingTCPServer.process_request_thread(
442
445
            self, request, client_address)
443
446
        self.close_request(request)
446
449
    def process_request(self, request, client_address):
447
450
        """Start a new thread to process the request."""
448
451
        started = threading.Event()
 
452
        detached = threading.Event()
449
453
        stopped = threading.Event()
450
454
        t = TestThread(
451
455
            sync_event=stopped,
452
456
            name='%s -> %s' % (client_address, self.server_address),
453
 
            target=self.process_request_thread,
454
 
            args=(started, stopped, request, client_address))
 
457
            target = self.process_request_thread,
 
458
            args = (started, detached, stopped, request, client_address))
455
459
        # Update the client description
456
460
        self.clients.pop()
457
461
        self.clients.append((request, client_address, t))
460
464
        t.set_ignored_exceptions(self.ignored_exceptions)
461
465
        t.start()
462
466
        started.wait()
463
 
        if debug_threads():
464
 
            sys.stderr.write('Client thread %s started\n' % (t.name,))
465
467
        # If an exception occured during the thread start, it will get raised.
466
 
        # In rare cases, an exception raised during the request processing may
467
 
        # also get caught here (see http://pad.lv/869366)
468
468
        t.pending_exception()
 
469
        if debug_threads():
 
470
            sys.stderr.write('Client thread %s started\n' % (t.name,))
 
471
        # Tell the thread, it's now on its own for exception handling.
 
472
        detached.set()
469
473
 
470
474
    # The following methods are called by the main thread
471
475