~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-07 16:52:24 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-20100607165224-9fl60mc25u3e958w
Fix broken test.

* bzrlib/tests/test_test_server.py:
(TestTCPServerInAThread.test_start_stop): Ouch, don't let the
client connect or the server will block waiting for some
input. That's not what the test is about.

* bzrlib/tests/test_server.py:
(TestingTCPServerMixin.handle_request): python's version swallow
some exxceptions we want to catch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
360
360
        finally:
361
361
            self.stopped.set()
362
362
 
 
363
    def handle_request(self):
 
364
        """Handle one request.
 
365
 
 
366
        The python version swallows some socket exceptions and we don't use
 
367
        timeout, so we override it to better control the server behavior.
 
368
        """
 
369
        request, client_address = self.get_request()
 
370
        if self.verify_request(request, client_address):
 
371
            try:
 
372
                self.process_request(request, client_address)
 
373
            except:
 
374
                self.handle_error(request, client_address)
 
375
                self.close_request(request)
 
376
 
363
377
    def verify_request(self, request, client_address):
364
378
        """Verify the request.
365
379
 
551
565
            return
552
566
        try:
553
567
            # The server has been started successfully, shut it down now.  As
554
 
            # soon as we stop serving, no more connection are accepted.
555
 
            self.server.serving.clear()
 
568
            # soon as we stop serving, no more connection are accepted except
 
569
            # one to get out of the blocking listen.
556
570
            self.set_ignored_exceptions(
557
571
                self.server.ignored_exceptions_during_shutdown)
 
572
            self.server.serving.clear()
558
573
            # The server is listening for a last connection, let's give it:
559
574
            last_conn = None
560
575
            try: