~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/smart/protocol.py

  • Committer: Aaron Bentley
  • Date: 2008-02-24 16:42:13 UTC
  • mfrom: (3234 +trunk)
  • mto: This revision was merged to the branch mainline in revision 3235.
  • Revision ID: aaron@aaronbentley.com-20080224164213-eza1lzru5bwuwmmj
Merge with bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
471
471
    def call(self, *args):
472
472
        if 'hpss' in debug.debug_flags:
473
473
            mutter('hpss call:   %s', repr(args)[1:-1])
 
474
            if getattr(self._request._medium, 'base', None) is not None:
 
475
                mutter('             (to %s)', self._request._medium.base)
474
476
            self._request_start_time = time.time()
475
477
        self._write_args(args)
476
478
        self._request.finished_writing()
482
484
        """
483
485
        if 'hpss' in debug.debug_flags:
484
486
            mutter('hpss call w/body: %s (%r...)', repr(args)[1:-1], body[:20])
 
487
            if getattr(self._request._medium, '_path', None) is not None:
 
488
                mutter('                  (to %s)', self._request._medium._path)
485
489
            mutter('              %d bytes', len(body))
486
490
            self._request_start_time = time.time()
 
491
            if 'hpssdetail' in debug.debug_flags:
 
492
                mutter('hpss body content: %s', body)
487
493
        self._write_args(args)
488
494
        bytes = self._encode_bulk_data(body)
489
495
        self._request.accept_bytes(bytes)
497
503
        """
498
504
        if 'hpss' in debug.debug_flags:
499
505
            mutter('hpss call w/readv: %s', repr(args)[1:-1])
 
506
            if getattr(self._request._medium, '_path', None) is not None:
 
507
                mutter('                  (to %s)', self._request._medium._path)
500
508
            self._request_start_time = time.time()
501
509
        self._write_args(args)
502
510
        readv_bytes = self._serialise_offsets(body)
543
551
            return self._body_buffer.read(count)
544
552
        _body_decoder = LengthPrefixedBodyDecoder()
545
553
 
 
554
        # Read no more than 64k at a time so that we don't risk error 10055 (no
 
555
        # buffer space available) on Windows.
 
556
        max_read = 64 * 1024
546
557
        while not _body_decoder.finished_reading:
547
 
            bytes_wanted = _body_decoder.next_read_size()
 
558
            bytes_wanted = min(_body_decoder.next_read_size(), max_read)
548
559
            bytes = self._request.read_bytes(bytes_wanted)
549
560
            _body_decoder.accept_bytes(bytes)
550
561
        self._request.finished_reading()
627
638
    def read_streamed_body(self):
628
639
        """Read bytes from the body, decoding into a byte stream.
629
640
        """
 
641
        # Read no more than 64k at a time so that we don't risk error 10055 (no
 
642
        # buffer space available) on Windows.
 
643
        max_read = 64 * 1024
630
644
        _body_decoder = ChunkedBodyDecoder()
631
645
        while not _body_decoder.finished_reading:
632
 
            bytes_wanted = _body_decoder.next_read_size()
 
646
            bytes_wanted = min(_body_decoder.next_read_size(), max_read)
633
647
            bytes = self._request.read_bytes(bytes_wanted)
634
648
            _body_decoder.accept_bytes(bytes)
635
649
            for body_bytes in iter(_body_decoder.read_next_chunk, None):