Rev 4912: (jam) Fix for -Dhpss server side. Threads don't have .get_ident(), in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Fri Dec 18 23:22:02 GMT 2009
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 4912 [merge]
revision-id: pqm at pqm.ubuntu.com-20091218232158-sc5b6z2upfgjf30u
parent: pqm at pqm.ubuntu.com-20091218174336-wrixy9etbc1yw8cf
parent: john at arbash-meinel.com-20091218221418-z5z2sgq6shohraw1
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Fri 2009-12-18 23:21:58 +0000
message:
(jam) Fix for -Dhpss server side. Threads don't have .get_ident(),
and py2.4/2.5 don't have .ident, fallback to .getName()
modified:
bzrlib/smart/medium.py medium.py-20061103051856-rgu2huy59fkz902q-1
bzrlib/smart/protocol.py protocol.py-20061108035435-ot0lstk2590yqhzr-1
bzrlib/smart/request.py request.py-20061108095550-gunadhxmzkdjfeek-1
bzrlib/tests/blackbox/test_serve.py test_serve.py-20060913064329-8t2pvmsikl4s3xhl-1
=== modified file 'bzrlib/smart/medium.py'
--- a/bzrlib/smart/medium.py 2009-12-11 21:57:03 +0000
+++ b/bzrlib/smart/medium.py 2009-12-18 22:14:18 +0000
@@ -300,7 +300,10 @@
tstart = osutils.timer_func()
osutils.send_all(self.socket, bytes, self._report_activity)
if 'hpss' in debug.debug_flags:
- thread_id = threading.currentThread().ident
+ cur_thread = threading.currentThread()
+ thread_id = getattr(cur_thread, 'ident', None)
+ if thread_id is None:
+ thread_id = cur_thread.getName()
trace.mutter('%12s: [%s] %d bytes to the socket in %.3fs'
% ('wrote', thread_id, len(bytes),
osutils.timer_func() - tstart))
=== modified file 'bzrlib/smart/protocol.py'
--- a/bzrlib/smart/protocol.py 2009-12-16 18:11:26 +0000
+++ b/bzrlib/smart/protocol.py 2009-12-18 22:14:18 +0000
@@ -1147,7 +1147,12 @@
self.response_sent = False
self._headers = {'Software version': bzrlib.__version__}
if 'hpss' in debug.debug_flags:
- self._thread_id = threading.currentThread().get_ident()
+ # python 2.6 introduced 'ident' as a nice small integer to
+ # represent a thread. But it doesn't exist in 2.4/2.5
+ cur_thread = threading.currentThread()
+ self._thread_id = getattr(cur_thread, 'ident', None)
+ if self._thread_id is None:
+ self._thread_id = cur_thread.getName()
self._response_start_time = None
def _trace(self, action, message, extra_bytes=None, include_time=False):
=== modified file 'bzrlib/smart/request.py'
--- a/bzrlib/smart/request.py 2009-12-14 16:16:05 +0000
+++ b/bzrlib/smart/request.py 2009-12-18 22:14:18 +0000
@@ -291,7 +291,10 @@
self._command = None
if 'hpss' in debug.debug_flags:
self._request_start_time = osutils.timer_func()
- self._thread_id = threading.currentThread().get_ident()
+ cur_thread = threading.currentThread()
+ self._thread_id = getattr(cur_thread, 'ident', None)
+ if self._thread_id is None:
+ self._thread_id = cur_thread.getName()
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
=== modified file 'bzrlib/tests/blackbox/test_serve.py'
--- a/bzrlib/tests/blackbox/test_serve.py 2009-11-25 13:21:52 +0000
+++ b/bzrlib/tests/blackbox/test_serve.py 2009-12-18 21:54:54 +0000
@@ -27,6 +27,7 @@
from bzrlib import (
builtins,
+ debug,
errors,
osutils,
revision as _mod_revision,
@@ -45,6 +46,7 @@
from bzrlib.trace import mutter
from bzrlib.transport import get_transport, remote
+
class TestBzrServeBase(TestCaseWithTransport):
def run_bzr_serve_then_func(self, serve_args, retcode=0, func=None,
@@ -130,7 +132,9 @@
finish_bzr_subprocess, a client for the server, and a transport.
"""
# Serve from the current directory
- process = self.start_bzr_subprocess(['serve', '--inet'])
+ args = ['serve', '--inet']
+ args.extend(extra_options)
+ process = self.start_bzr_subprocess(args)
# Connect to the server
# We use this url because while this is no valid URL to connect to this
@@ -180,9 +184,10 @@
process, transport = self.start_server_inet(['--allow-writes'])
- # We get a working branch
+ # We get a working branch, and can create a directory
branch = BzrDir.open_from_transport(transport).open_branch()
self.make_read_requests(branch)
+ transport.mkdir('adir')
self.assertInetServerShutsdownCleanly(process)
def test_bzr_serve_port_readonly(self):
@@ -215,6 +220,21 @@
self.make_read_requests(branch)
self.assertServerFinishesCleanly(process)
+ def test_bzr_serve_dhpss(self):
+ # This is a smoke test that the server doesn't crash when run with
+ # -Dhpss, and does drop some hpss logging to the file.
+ self.make_branch('.')
+ log_fname = os.getcwd() + '/server.log'
+ self._captureVar('BZR_LOG', log_fname)
+ process, transport = self.start_server_inet(['-Dhpss'])
+ branch = BzrDir.open_from_transport(transport).open_branch()
+ self.make_read_requests(branch)
+ self.assertInetServerShutsdownCleanly(process)
+ f = open(log_fname, 'rb')
+ content = f.read()
+ f.close()
+ self.assertContainsRe(content, 'hpss request: \[')
+
class TestCmdServeChrooting(TestBzrServeBase):
More information about the bazaar-commits
mailing list