/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: Martin Pool
  • Date: 2010-10-08 04:38:25 UTC
  • mfrom: (5462 +trunk)
  • mto: This revision was merged to the branch mainline in revision 5478.
  • Revision ID: mbp@sourcefrog.net-20101008043825-b181r8bo5r3qwb6j
merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006, 2007, 2008, 2009 Canonical Ltd
 
1
# Copyright (C) 2006-2010 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
 
61
62
 
62
63
def _encode_tuple(args):
63
64
    """Encode the tuple args to a bytestream."""
64
 
    return '\x01'.join(args) + '\n'
 
65
    joined = '\x01'.join(args) + '\n'
 
66
    if type(joined) is unicode:
 
67
        # XXX: We should fix things so this never happens!  -AJB, 20100304
 
68
        mutter('response args contain unicode, should be only bytes: %r',
 
69
               joined)
 
70
        joined = joined.encode('ascii')
 
71
    return joined
65
72
 
66
73
 
67
74
class Requester(object):
1147
1154
        self.response_sent = False
1148
1155
        self._headers = {'Software version': bzrlib.__version__}
1149
1156
        if 'hpss' in debug.debug_flags:
1150
 
            # python 2.6 introduced 'ident' as a nice small integer to
1151
 
            # represent a thread. But it doesn't exist in 2.4/2.5
1152
 
            cur_thread = threading.currentThread()
1153
 
            self._thread_id = getattr(cur_thread, 'ident', None)
1154
 
            if self._thread_id is None:
1155
 
                self._thread_id = cur_thread.getName()
 
1157
            self._thread_id = thread.get_ident()
1156
1158
            self._response_start_time = None
1157
1159
 
1158
1160
    def _trace(self, action, message, extra_bytes=None, include_time=False):
1229
1231
                    if first_chunk is None:
1230
1232
                        first_chunk = chunk
1231
1233
                    self._write_prefixed_body(chunk)
 
1234
                    self.flush()
1232
1235
                    if 'hpssdetail' in debug.debug_flags:
1233
1236
                        # Not worth timing separately, as _write_func is
1234
1237
                        # actually buffered