~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/smart/protocol.py

  • Committer: Patch Queue Manager
  • Date: 2016-02-01 19:13:13 UTC
  • mfrom: (6614.2.2 trunk)
  • Revision ID: pqm@pqm.ubuntu.com-20160201191313-wdfvmfff1djde6oq
(vila) Release 2.7.0 (Vincent Ladeuil)

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
 
21
23
import collections
22
24
from cStringIO import StringIO
23
25
import struct
24
26
import sys
25
27
import thread
26
 
import threading
27
28
import time
28
29
 
29
30
import bzrlib
1081
1082
        self._real_write_func = write_func
1082
1083
 
1083
1084
    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
1087
1085
        # TODO: Another possibility would be to turn this into an async model.
1088
1086
        #       Where we let another thread know that we have some bytes if
1089
1087
        #       they want it, but we don't actually block for it
1292
1290
        _ProtocolThreeEncoder.__init__(self, medium_request.accept_bytes)
1293
1291
        self._medium_request = medium_request
1294
1292
        self._headers = {}
 
1293
        self.body_stream_started = None
1295
1294
 
1296
1295
    def set_headers(self, headers):
1297
1296
        self._headers = headers.copy()
1357
1356
            if path is not None:
1358
1357
                mutter('                  (to %s)', path)
1359
1358
            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
1367
1370
        for exc_info, part in _iter_with_errors(stream):
1368
1371
            if exc_info is not None:
1369
1372
                # Iterating the stream failed.  Cleanly abort the request.