Rev 4207: (andrew) Fix BzrDir.open in non-main (and non-server-request) thread in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Thu Mar 26 11:48:22 GMT 2009


At file:///home/pqm/archives/thelove/bzr/%2Btrunk/

------------------------------------------------------------
revno: 4207
revision-id: pqm at pqm.ubuntu.com-20090326113126-bj9spvf4ixrywxu3
parent: pqm at pqm.ubuntu.com-20090326063330-evutyvml3067dpsz
parent: andrew.bennetts at canonical.com-20090326065915-n5vmwse4axfc5qhn
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Thu 2009-03-26 11:31:26 +0000
message:
  (andrew) Fix BzrDir.open in non-main (and non-server-request) thread
  	when bzrlib.smart.request's _pre_open_hook is installed.
modified:
  bzrlib/smart/request.py        request.py-20061108095550-gunadhxmzkdjfeek-1
  bzrlib/tests/test_smart_request.py test_smart_request.p-20090211070731-o38wayv3asm25d6a-1
    ------------------------------------------------------------
    revno: 4205.2.1
    revision-id: andrew.bennetts at canonical.com-20090326065915-n5vmwse4axfc5qhn
    parent: pqm at pqm.ubuntu.com-20090326001427-mnhqpak56tlqa5e7
    committer: Andrew Bennetts <andrew.bennetts at canonical.com>
    branch nick: jail_info_thread_bug
    timestamp: Thu 2009-03-26 17:59:15 +1100
    message:
      Fix BzrDir.open in non-main (and non-server-request) thread when bzrlib.smart.request's _pre_open_hook is installed.
    modified:
      bzrlib/smart/request.py        request.py-20061108095550-gunadhxmzkdjfeek-1
      bzrlib/tests/test_smart_request.py test_smart_request.p-20090211070731-o38wayv3asm25d6a-1
=== modified file 'bzrlib/smart/request.py'
--- a/bzrlib/smart/request.py	2009-03-24 06:40:26 +0000
+++ b/bzrlib/smart/request.py	2009-03-26 06:59:15 +0000
@@ -58,7 +58,7 @@
 
 
 def _pre_open_hook(transport):
-    allowed_transports = jail_info.transports
+    allowed_transports = getattr(jail_info, 'transports', None)
     if allowed_transports is None:
         return
     abspath = transport.base

=== modified file 'bzrlib/tests/test_smart_request.py'
--- a/bzrlib/tests/test_smart_request.py	2009-03-24 06:40:26 +0000
+++ b/bzrlib/tests/test_smart_request.py	2009-03-26 06:59:15 +0000
@@ -19,6 +19,7 @@
 import threading
 
 from bzrlib import errors
+from bzrlib.bzrdir import BzrDir
 from bzrlib.smart import request
 from bzrlib.tests import TestCase, TestCaseWithMemoryTransport
 from bzrlib.transport import get_transport
@@ -203,3 +204,21 @@
         self.assertRaises(
             errors.BzrError, _pre_open_hook, get_transport('http://host/'))
 
+    def test_open_bzrdir_in_non_main_thread(self):
+        """Opening a bzrdir in a non-main thread should work ok.
+        
+        This makes sure that the globally-installed
+        bzrlib.smart.request._pre_open_hook, which uses a threading.local(),
+        works in a newly created thread.
+        """
+        bzrdir = self.make_bzrdir('.')
+        transport = bzrdir.root_transport
+        thread_result = []
+        def t():
+            BzrDir.open_from_transport(transport)
+            thread_result.append('ok')
+        thread = threading.Thread(target=t)
+        thread.start()
+        thread.join()
+        self.assertEqual(['ok'], thread_result)
+




More information about the bazaar-commits mailing list