~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/smart/medium.py

Merge loom thread.

Show diffs side-by-side

added added

removed removed

Lines of Context:
395
395
 
396
396
    def __init__(self):
397
397
        super(SmartClientMedium, self).__init__()
 
398
        self._protocol_version_error = None
398
399
        self._protocol_version = None
399
400
 
400
401
    def protocol_version(self):
401
402
        """Find out the best protocol version to use."""
 
403
        if self._protocol_version_error is not None:
 
404
            raise self._protocol_version_error
402
405
        if self._protocol_version is None:
403
 
            medium_request = self.get_request()
404
 
            # Send a 'hello' request in protocol version one, for maximum
405
 
            # backwards compatibility.
406
 
            client_protocol = SmartClientRequestProtocolOne(medium_request)
407
 
            self._protocol_version = client_protocol.query_version()
 
406
            try:
 
407
                medium_request = self.get_request()
 
408
                # Send a 'hello' request in protocol version one, for maximum
 
409
                # backwards compatibility.
 
410
                client_protocol = SmartClientRequestProtocolOne(medium_request)
 
411
                self._protocol_version = client_protocol.query_version()
 
412
            except errors.SmartProtocolError, e:
 
413
                # Cache the error, just like we would cache a successful
 
414
                # result.
 
415
                self._protocol_version_error = e
 
416
                raise
408
417
        return self._protocol_version
409
418
 
410
419
    def disconnect(self):