/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/tests/test_server.py

  • Committer: Jelmer Vernooij
  • Date: 2018-11-16 23:19:12 UTC
  • mfrom: (7180 work)
  • mto: This revision was merged to the branch mainline in revision 7294.
  • Revision ID: jelmer@jelmer.uk-20181116231912-e043vpq22bdkxa6q
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
    import SocketServer as socketserver
23
23
import sys
24
24
import threading
25
 
import traceback
26
25
 
27
26
 
28
27
from breezy import (
267
266
            # platforms, this doesn't occur, so just mentioning the problem is
268
267
            # enough for now -- vila 2010824
269
268
            sys.stderr.write('thread %s hung\n' % (self.name,))
270
 
            #raise AssertionError('thread %s hung' % (self.name,))
 
269
            # raise AssertionError('thread %s hung' % (self.name,))
271
270
 
272
271
 
273
272
class TestingTCPServerMixin(object):
314
313
        if self.verify_request(request, client_address):
315
314
            try:
316
315
                self.process_request(request, client_address)
317
 
            except:
 
316
            except BaseException:
318
317
                self.handle_error(request, client_address)
319
318
        else:
320
319
            self.close_request(request)
457
456
        t = TestThread(
458
457
            sync_event=stopped,
459
458
            name='%s -> %s' % (client_address, self.server_address),
460
 
            target = self.process_request_thread,
461
 
            args = (started, detached, stopped, request, client_address))
 
459
            target=self.process_request_thread,
 
460
            args=(started, detached, stopped, request, client_address))
462
461
        # Update the client description
463
462
        self.clients.pop()
464
463
        self.clients.append((request, client_address, t))
562
561
            last_conn = None
563
562
            try:
564
563
                last_conn = osutils.connect_socket((self.host, self.port))
565
 
            except socket.error as e:
 
564
            except socket.error:
566
565
                # But ignore connection errors as the point is to unblock the
567
566
                # server thread, it may happen that it's not blocked or even
568
567
                # not started.
626
625
 
627
626
_DEFAULT_TESTING_CLIENT_TIMEOUT = 60.0
628
627
 
 
628
 
629
629
class TestingSmartServer(TestingThreadingTCPServer, server.SmartTCPServer):
630
630
 
631
631
    def __init__(self, server_address, request_handler_class,
632
632
                 backing_transport, root_client_path):
633
633
        TestingThreadingTCPServer.__init__(self, server_address,
634
634
                                           request_handler_class)
635
 
        server.SmartTCPServer.__init__(self, backing_transport,
 
635
        server.SmartTCPServer.__init__(
 
636
            self, backing_transport,
636
637
            root_client_path, client_timeout=_DEFAULT_TESTING_CLIENT_TIMEOUT)
637
638
 
638
639
    def serve(self):
652
653
 
653
654
    This server is backed by the process's cwd.
654
655
    """
 
656
 
655
657
    def __init__(self, thread_name_suffix=''):
656
658
        self.client_path_extra = None
657
659
        self.thread_name_suffix = thread_name_suffix
658
660
        self.host = '127.0.0.1'
659
661
        self.port = 0
660
662
        super(SmartTCPServer_for_testing, self).__init__(
661
 
                (self.host, self.port),
662
 
                TestingSmartServer,
663
 
                TestingSmartConnectionHandler)
 
663
            (self.host, self.port),
 
664
            TestingSmartServer,
 
665
            TestingSmartConnectionHandler)
664
666
 
665
667
    def create_server(self):
666
668
        return self.server_class((self.host, self.port),
668
670
                                 self.backing_transport,
669
671
                                 self.root_client_path)
670
672
 
671
 
 
672
673
    def start_server(self, backing_transport_server=None,
673
674
                     client_path_extra='/extra/'):
674
675
        """Set up server for testing.
737
738
 
738
739
 
739
740
class ReadonlySmartTCPServer_for_testing_v2_only(
740
 
    SmartTCPServer_for_testing_v2_only):
 
741
        SmartTCPServer_for_testing_v2_only):
741
742
    """Get a readonly server for testing."""
742
743
 
743
744
    def get_backing_transport(self, backing_transport_server):