/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 bzrlib/smart/medium.py

  • Committer: Martin Pool
  • Date: 2009-09-11 06:36:50 UTC
  • mto: This revision was merged to the branch mainline in revision 4688.
  • Revision ID: mbp@sourcefrog.net-20090911063650-yvb522sbe6k0i62r
Only mutter extension load errors when they occur, and record for later

Show diffs side-by-side

added added

removed removed

Lines of Context:
37
37
from bzrlib import (
38
38
    debug,
39
39
    errors,
 
40
    osutils,
40
41
    symbol_versioning,
41
42
    trace,
42
43
    ui,
45
46
from bzrlib.smart import client, protocol, request, vfs
46
47
from bzrlib.transport import ssh
47
48
""")
48
 
#usually already imported, and getting IllegalScoperReplacer on it here.
49
 
from bzrlib import osutils
 
49
 
50
50
 
51
51
# We must not read any more than 64k at a time so we don't risk "no buffer
52
52
# space available" errors on some platforms.  Windows in particular is likely
291
291
    def terminate_due_to_error(self):
292
292
        # TODO: This should log to a server log file, but no such thing
293
293
        # exists yet.  Andrew Bennetts 2006-09-29.
294
 
        osutils.until_no_eintr(self.socket.close)
 
294
        self.socket.close()
295
295
        self.finished = True
296
296
 
297
297
    def _write_out(self, bytes):
326
326
            bytes_to_read = protocol.next_read_size()
327
327
            if bytes_to_read == 0:
328
328
                # Finished serving this request.
329
 
                osutils.until_no_eintr(self._out.flush)
 
329
                self._out.flush()
330
330
                return
331
331
            bytes = self.read_bytes(bytes_to_read)
332
332
            if bytes == '':
333
333
                # Connection has been closed.
334
334
                self.finished = True
335
 
                osutils.until_no_eintr(self._out.flush)
 
335
                self._out.flush()
336
336
                return
337
337
            protocol.accept_bytes(bytes)
338
338
 
339
339
    def _read_bytes(self, desired_count):
340
 
        return osutils.until_no_eintr(self._in.read, desired_count)
 
340
        return self._in.read(desired_count)
341
341
 
342
342
    def terminate_due_to_error(self):
343
343
        # TODO: This should log to a server log file, but no such thing
344
344
        # exists yet.  Andrew Bennetts 2006-09-29.
345
 
        osutils.until_no_eintr(self._out.close)
 
345
        self._out.close()
346
346
        self.finished = True
347
347
 
348
348
    def _write_out(self, bytes):
349
 
        osutils.until_no_eintr(self._out.write, bytes)
 
349
        self._out.write(bytes)
350
350
 
351
351
 
352
352
class SmartClientMediumRequest(object):
712
712
 
713
713
    def _accept_bytes(self, bytes):
714
714
        """See SmartClientStreamMedium.accept_bytes."""
715
 
        osutils.until_no_eintr(self._writeable_pipe.write, bytes)
 
715
        self._writeable_pipe.write(bytes)
716
716
        self._report_activity(len(bytes), 'write')
717
717
 
718
718
    def _flush(self):
719
719
        """See SmartClientStreamMedium._flush()."""
720
 
        osutils.until_no_eintr(self._writeable_pipe.flush)
 
720
        self._writeable_pipe.flush()
721
721
 
722
722
    def _read_bytes(self, count):
723
723
        """See SmartClientStreamMedium._read_bytes."""
724
 
        bytes = osutils.until_no_eintr(self._readable_pipe.read, count)
 
724
        bytes = self._readable_pipe.read(count)
725
725
        self._report_activity(len(bytes), 'read')
726
726
        return bytes
727
727
 
765
765
    def _accept_bytes(self, bytes):
766
766
        """See SmartClientStreamMedium.accept_bytes."""
767
767
        self._ensure_connection()
768
 
        osutils.until_no_eintr(self._write_to.write, bytes)
 
768
        self._write_to.write(bytes)
769
769
        self._report_activity(len(bytes), 'write')
770
770
 
771
771
    def disconnect(self):
772
772
        """See SmartClientMedium.disconnect()."""
773
773
        if not self._connected:
774
774
            return
775
 
        osutils.until_no_eintr(self._read_from.close)
776
 
        osutils.until_no_eintr(self._write_to.close)
 
775
        self._read_from.close()
 
776
        self._write_to.close()
777
777
        self._ssh_connection.close()
778
778
        self._connected = False
779
779
 
802
802
        if not self._connected:
803
803
            raise errors.MediumNotConnected(self)
804
804
        bytes_to_read = min(count, _MAX_READ_SIZE)
805
 
        bytes = osutils.until_no_eintr(self._read_from.read, bytes_to_read)
 
805
        bytes = self._read_from.read(bytes_to_read)
806
806
        self._report_activity(len(bytes), 'read')
807
807
        return bytes
808
808
 
832
832
        """See SmartClientMedium.disconnect()."""
833
833
        if not self._connected:
834
834
            return
835
 
        osutils.until_no_eintr(self._socket.close)
 
835
        self._socket.close()
836
836
        self._socket = None
837
837
        self._connected = False
838
838