/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/protocol.py

  • Committer: John Arbash Meinel
  • Date: 2010-01-12 22:36:23 UTC
  • mfrom: (4953 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4955.
  • Revision ID: john@arbash-meinel.com-20100112223623-836x5mou0gm5vsep
merge bzr.dev 4953 to clean up the ui factory issues

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006, 2007 Canonical Ltd
 
1
# Copyright (C) 2006, 2007, 2008, 2009 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
22
22
from cStringIO import StringIO
23
23
import struct
24
24
import sys
 
25
import thread
25
26
import threading
26
27
import time
27
28
 
1066
1067
class _ProtocolThreeEncoder(object):
1067
1068
 
1068
1069
    response_marker = request_marker = MESSAGE_VERSION_THREE
 
1070
    BUFFER_SIZE = 1024*1024 # 1 MiB buffer before flushing
1069
1071
 
1070
1072
    def __init__(self, write_func):
1071
1073
        self._buf = []
 
1074
        self._buf_len = 0
1072
1075
        self._real_write_func = write_func
1073
1076
 
1074
1077
    def _write_func(self, bytes):
1081
1084
        #       Note that osutils.send_all always sends 64kB chunks anyway, so
1082
1085
        #       we might just push out smaller bits at a time?
1083
1086
        self._buf.append(bytes)
1084
 
        if len(self._buf) > 100:
 
1087
        self._buf_len += len(bytes)
 
1088
        if self._buf_len > self.BUFFER_SIZE:
1085
1089
            self.flush()
1086
1090
 
1087
1091
    def flush(self):
1088
1092
        if self._buf:
1089
1093
            self._real_write_func(''.join(self._buf))
1090
1094
            del self._buf[:]
 
1095
            self._buf_len = 0
1091
1096
 
1092
1097
    def _serialise_offsets(self, offsets):
1093
1098
        """Serialise a readv offset list."""
1143
1148
        self.response_sent = False
1144
1149
        self._headers = {'Software version': bzrlib.__version__}
1145
1150
        if 'hpss' in debug.debug_flags:
1146
 
            self._thread_id = threading.currentThread().get_ident()
 
1151
            self._thread_id = thread.get_ident()
1147
1152
            self._response_start_time = None
1148
1153
 
1149
1154
    def _trace(self, action, message, extra_bytes=None, include_time=False):