def _write_out(self, bytes): tstart = osutils.timer_func() osutils.send_all(self.socket, bytes, self._report_activity) if 'hpss' in debug.debug_flags: thread_id = thread.get_ident() trace.mutter('%12s: [%s] %d bytes to the socket in %.3fs' % ('wrote', thread_id, len(bytes), osutils.timer_func() - tstart))
def _trace(self, action, message, extra_bytes=None, include_time=False): # It is a bit of a shame that this functionality overlaps with that of # ProtocolThreeRequester._trace. However, there is enough difference # that just putting it in a helper doesn't help a lot. And some state # is taken from the instance. if include_time: t = '%5.3fs ' % (osutils.timer_func() - self._request_start_time) else: t = '' if extra_bytes is None: extra = '' else: extra = ' ' + repr(extra_bytes[:40]) if len(extra) > 33: extra = extra[:29] + extra[-1] + '...' trace.mutter('%12s: [%s] %s%s%s' % (action, self._thread_id, t, message, extra))
def __init__(self, backing_transport, commands, root_client_path, jail_root=None): """Constructor. :param backing_transport: a Transport to handle requests for. :param commands: a registry mapping command names to SmartServerRequest subclasses. e.g. bzrlib.transport.smart.vfs.vfs_commands. """ self._backing_transport = backing_transport self._root_client_path = root_client_path self._commands = commands if jail_root is None: jail_root = backing_transport self._jail_root = jail_root self.response = None self.finished_reading = False self._command = None if 'hpss' in debug.debug_flags: self._request_start_time = osutils.timer_func() self._thread_id = thread.get_ident()