~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_lockdir.py

  • Committer: Martin Pool
  • Date: 2007-07-04 09:21:56 UTC
  • mto: This revision was merged to the branch mainline in revision 2584.
  • Revision ID: mbp@sourcefrog.net-20070704092156-us6h516qevsps4dg
Remove LockDir.wait()

Show diffs side-by-side

added added

removed removed

Lines of Context:
268
268
        self.assertEndsWith(args[3], ' ago')
269
269
        self.assertContainsRe(args[4], r'\d\d:\d\d:\d\d')
270
270
 
271
 
    def test_33_wait(self):
272
 
        """Succeed when waiting on a lock that gets released
273
 
 
274
 
        The difference from test_32_lock_wait_succeed is that the second 
275
 
        caller does not actually acquire the lock, but just waits for it
276
 
        to be released.  This is done over a readonly transport.
277
 
        """
278
 
        t = self.get_transport()
279
 
        lf1 = LockDir(t, 'test_lock')
280
 
        lf1.create()
281
 
        lf1.attempt_lock()
282
 
 
283
 
        def wait_and_unlock():
284
 
            time.sleep(0.1)
285
 
            lf1.unlock()
286
 
        unlocker = Thread(target=wait_and_unlock)
287
 
        unlocker.start()
288
 
        try:
289
 
            lf2 = LockDir(self.get_readonly_transport(), 'test_lock')
290
 
            before = time.time()
291
 
            # wait but don't lock
292
 
            lf2.wait(timeout=0.4, poll=0.1)
293
 
            after = time.time()
294
 
            self.assertTrue(after - before <= 1.0)
295
 
        finally:
296
 
            unlocker.join()
297
 
 
298
271
    def test_34_lock_write_waits(self):
299
272
        """LockDir.lock_write() will wait for the lock.""" 
300
273
        # the test suite sets the default to 0 to make deadlocks fail fast.