~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/smart/protocol.py

  • Committer: Andrew Bennetts
  • Date: 2010-10-08 08:15:14 UTC
  • mto: This revision was merged to the branch mainline in revision 5498.
  • Revision ID: andrew.bennetts@canonical.com-20101008081514-dviqzrdfwyzsqbz2
Split NEWS into per-release doc/en/release-notes/bzr-*.txt

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
client and server.
19
19
"""
20
20
 
21
 
from __future__ import absolute_import
22
 
 
23
21
import collections
24
22
from cStringIO import StringIO
25
23
import struct
26
24
import sys
27
25
import thread
 
26
import threading
28
27
import time
29
28
 
30
29
import bzrlib
655
654
        """Make a remote call with a readv array.
656
655
 
657
656
        The body is encoded with one line per readv offset pair. The numbers in
658
 
        each pair are separated by a comma, and no trailing \\n is emitted.
 
657
        each pair are separated by a comma, and no trailing \n is emitted.
659
658
        """
660
659
        if 'hpss' in debug.debug_flags:
661
660
            mutter('hpss call w/readv: %s', repr(args)[1:-1])
1082
1081
        self._real_write_func = write_func
1083
1082
 
1084
1083
    def _write_func(self, bytes):
 
1084
        # TODO: It is probably more appropriate to use sum(map(len, _buf))
 
1085
        #       for total number of bytes to write, rather than buffer based on
 
1086
        #       the number of write() calls
1085
1087
        # TODO: Another possibility would be to turn this into an async model.
1086
1088
        #       Where we let another thread know that we have some bytes if
1087
1089
        #       they want it, but we don't actually block for it
1290
1292
        _ProtocolThreeEncoder.__init__(self, medium_request.accept_bytes)
1291
1293
        self._medium_request = medium_request
1292
1294
        self._headers = {}
1293
 
        self.body_stream_started = None
1294
1295
 
1295
1296
    def set_headers(self, headers):
1296
1297
        self._headers = headers.copy()
1331
1332
        """Make a remote call with a readv array.
1332
1333
 
1333
1334
        The body is encoded with one line per readv offset pair. The numbers in
1334
 
        each pair are separated by a comma, and no trailing \\n is emitted.
 
1335
        each pair are separated by a comma, and no trailing \n is emitted.
1335
1336
        """
1336
1337
        if 'hpss' in debug.debug_flags:
1337
1338
            mutter('hpss call w/readv: %s', repr(args)[1:-1])
1356
1357
            if path is not None:
1357
1358
                mutter('                  (to %s)', path)
1358
1359
            self._request_start_time = osutils.timer_func()
1359
 
        self.body_stream_started = False
1360
1360
        self._write_protocol_version()
1361
1361
        self._write_headers(self._headers)
1362
1362
        self._write_structure(args)
1364
1364
        #       have finished sending the stream.  We would notice at the end
1365
1365
        #       anyway, but if the medium can deliver it early then it's good
1366
1366
        #       to short-circuit the whole request...
1367
 
        # Provoke any ConnectionReset failures before we start the body stream.
1368
 
        self.flush()
1369
 
        self.body_stream_started = True
1370
1367
        for exc_info, part in _iter_with_errors(stream):
1371
1368
            if exc_info is not None:
1372
1369
                # Iterating the stream failed.  Cleanly abort the request.