Rev 2576: Remove LockDir.wait() in http://sourcefrog.net/bzr/dlock

Martin Pool mbp at sourcefrog.net
Wed Jul 4 10:21:57 BST 2007


At http://sourcefrog.net/bzr/dlock

------------------------------------------------------------
revno: 2576
revision-id: mbp at sourcefrog.net-20070704092156-us6h516qevsps4dg
parent: mbp at sourcefrog.net-20070704091023-7ngb0ux89dnxbppi
committer: Martin Pool <mbp at sourcefrog.net>
branch nick: dlock
timestamp: Wed 2007-07-04 19:21:56 +1000
message:
  Remove LockDir.wait()
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/lockdir.py              lockdir.py-20060220222025-98258adf27fbdda3
  bzrlib/tests/test_lockdir.py   test_lockdir.py-20060220222025-33d4221569a3d600
=== modified file 'NEWS'
--- a/NEWS	2007-07-04 09:04:20 +0000
+++ b/NEWS	2007-07-04 09:21:56 +0000
@@ -119,6 +119,8 @@
     * ``bzrlib.add.FastPath`` is now private and moved to 
       ``bzrlib.mutabletree._FastPath``. (Robert Collins, Martin Pool)
 
+    * ``LockDir.wait`` removed.  (Martin Pool)
+
   INTERNALS:
 
     * New SMTPConnection class to unify email handling.  (Adeodato Simó)

=== modified file 'bzrlib/lockdir.py'
--- a/bzrlib/lockdir.py	2007-07-04 09:10:23 +0000
+++ b/bzrlib/lockdir.py	2007-07-04 09:21:56 +0000
@@ -570,25 +570,6 @@
             raise LockContention(self)
         self._fake_read_lock = True
 
-    def wait(self, timeout=20, poll=0.5):
-        """Wait a certain period for a lock to be released."""
-        # XXX: the transport interface doesn't let us guard 
-        # against operations there taking a long time.
-        #
-        # XXX: Is this really needed?  Do people want to wait for the lock but
-        # not acquire it?  As of bzr 0.17, this seems to only be called from
-        # the test suite.
-        deadline = time.time() + timeout
-        while True:
-            if self.peek():
-                return
-            if time.time() + poll < deadline:
-                self._trace("waiting %ss", poll)
-                time.sleep(poll)
-            else:
-                self._trace("timeout after waiting %ss", timeout)
-                raise LockContention(self)
-
     def _format_lock_info(self, info):
         """Turn the contents of peek() into something for the user"""
         lock_url = self.transport.abspath(self.path)

=== modified file 'bzrlib/tests/test_lockdir.py'
--- a/bzrlib/tests/test_lockdir.py	2007-07-03 09:09:19 +0000
+++ b/bzrlib/tests/test_lockdir.py	2007-07-04 09:21:56 +0000
@@ -268,33 +268,6 @@
         self.assertEndsWith(args[3], ' ago')
         self.assertContainsRe(args[4], r'\d\d:\d\d:\d\d')
 
-    def test_33_wait(self):
-        """Succeed when waiting on a lock that gets released
-
-        The difference from test_32_lock_wait_succeed is that the second 
-        caller does not actually acquire the lock, but just waits for it
-        to be released.  This is done over a readonly transport.
-        """
-        t = self.get_transport()
-        lf1 = LockDir(t, 'test_lock')
-        lf1.create()
-        lf1.attempt_lock()
-
-        def wait_and_unlock():
-            time.sleep(0.1)
-            lf1.unlock()
-        unlocker = Thread(target=wait_and_unlock)
-        unlocker.start()
-        try:
-            lf2 = LockDir(self.get_readonly_transport(), 'test_lock')
-            before = time.time()
-            # wait but don't lock
-            lf2.wait(timeout=0.4, poll=0.1)
-            after = time.time()
-            self.assertTrue(after - before <= 1.0)
-        finally:
-            unlocker.join()
-
     def test_34_lock_write_waits(self):
         """LockDir.lock_write() will wait for the lock.""" 
         # the test suite sets the default to 0 to make deadlocks fail fast.




More information about the bazaar-commits mailing list