当前位置: 首页>>代码示例>>Python>>正文


Python LockDir.unlock方法代码示例

本文整理汇总了Python中bzrlib.lockdir.LockDir.unlock方法的典型用法代码示例。如果您正苦于以下问题:Python LockDir.unlock方法的具体用法?Python LockDir.unlock怎么用?Python LockDir.unlock使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在bzrlib.lockdir.LockDir的用法示例。


在下文中一共展示了LockDir.unlock方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_30_lock_wait_fail

# 需要导入模块: from bzrlib.lockdir import LockDir [as 别名]
# 或者: from bzrlib.lockdir.LockDir import unlock [as 别名]
    def test_30_lock_wait_fail(self):
        """Wait on a lock, then fail

        We ask to wait up to 400ms; this should fail within at most one
        second.  (Longer times are more realistic but we don't want the test
        suite to take too long, and this should do for now.)
        """
        t = self.get_transport()
        lf1 = LockDir(t, 'test_lock')
        lf1.create()
        lf2 = LockDir(t, 'test_lock')
        self.setup_log_reporter(lf2)
        lf1.attempt_lock()
        try:
            before = time.time()
            self.assertRaises(LockContention, lf2.wait_lock,
                              timeout=0.4, poll=0.1)
            after = time.time()
            # it should only take about 0.4 seconds, but we allow more time in
            # case the machine is heavily loaded
            self.assertTrue(after - before <= 8.0,
                "took %f seconds to detect lock contention" % (after - before))
        finally:
            lf1.unlock()
        self.assertEqual(1, len(self._logged_reports))
        self.assertContainsRe(self._logged_reports[0][0],
            r'Unable to obtain lock .* held by [email protected]\.com on .*'
            r' \(process #\d+\), acquired .* ago\.\n'
            r'Will continue to try until \d{2}:\d{2}:\d{2}, unless '
            r'you press Ctrl-C.\n'
            r'See "bzr help break-lock" for more.')
开发者ID:GymWenFLL,项目名称:tpp_libs,代码行数:33,代码来源:test_lockdir.py

示例2: test_missing_lockdir_info

# 需要导入模块: from bzrlib.lockdir import LockDir [as 别名]
# 或者: from bzrlib.lockdir.LockDir import unlock [as 别名]
 def test_missing_lockdir_info(self):
     """We can cope with absent info files."""
     t = self.get_transport()
     t.mkdir('test_lock')
     t.mkdir('test_lock/held')
     lf = LockDir(t, 'test_lock')
     # In this case we expect the 'not held' result from peek, because peek
     # cannot be expected to notice that there is a 'held' directory with no
     # 'info' file.
     self.assertEqual(None, lf.peek())
     # And lock/unlock may work or give LockContention (but not any other
     # error).
     try:
         lf.attempt_lock()
     except LockContention:
         # LockContention is ok, and expected on Windows
         pass
     else:
         # no error is ok, and expected on POSIX (because POSIX allows
         # os.rename over an empty directory).
         lf.unlock()
     # Currently raises TokenMismatch, but LockCorrupt would be reasonable
     # too.
     self.assertRaises(
         (errors.TokenMismatch, errors.LockCorrupt),
         lf.validate_token, 'fake token')
开发者ID:GymWenFLL,项目名称:tpp_libs,代码行数:28,代码来源:test_lockdir.py

示例3: test_10_lock_uncontested

# 需要导入模块: from bzrlib.lockdir import LockDir [as 别名]
# 或者: from bzrlib.lockdir.LockDir import unlock [as 别名]
 def test_10_lock_uncontested(self):
     """Acquire and release a lock"""
     t = self.get_transport()
     lf = LockDir(t, 'test_lock')
     lf.create()
     lf.attempt_lock()
     try:
         self.assertTrue(lf.is_held)
     finally:
         lf.unlock()
         self.assertFalse(lf.is_held)
开发者ID:GymWenFLL,项目名称:tpp_libs,代码行数:13,代码来源:test_lockdir.py

示例4: test_42_confirm_broken_manually

# 需要导入模块: from bzrlib.lockdir import LockDir [as 别名]
# 或者: from bzrlib.lockdir.LockDir import unlock [as 别名]
 def test_42_confirm_broken_manually(self):
     """Confirm a lock broken by hand"""
     t = self.get_transport()
     lf1 = LockDir(t, 'test_lock')
     lf1.create()
     lf1.attempt_lock()
     t.move('test_lock', 'lock_gone_now')
     self.assertRaises(LockBroken, lf1.confirm)
     # Clean up
     t.move('lock_gone_now', 'test_lock')
     lf1.unlock()
开发者ID:GymWenFLL,项目名称:tpp_libs,代码行数:13,代码来源:test_lockdir.py

示例5: test_lock_with_buggy_rename

# 需要导入模块: from bzrlib.lockdir import LockDir [as 别名]
# 或者: from bzrlib.lockdir.LockDir import unlock [as 别名]
 def test_lock_with_buggy_rename(self):
     # test that lock acquisition handles servers which pretend they
     # renamed correctly but that actually fail
     t = transport.get_transport('brokenrename+' + self.get_url())
     ld1 = LockDir(t, 'test_lock')
     ld1.create()
     ld1.attempt_lock()
     ld2 = LockDir(t, 'test_lock')
     # we should fail to lock
     e = self.assertRaises(errors.LockContention, ld2.attempt_lock)
     # now the original caller should succeed in unlocking
     ld1.unlock()
     # and there should be nothing left over
     self.assertEquals([], t.list_dir('test_lock'))
开发者ID:c0ns0le,项目名称:cygwin,代码行数:16,代码来源:test_lockdir.py

示例6: test_50_lockdir_representation

# 需要导入模块: from bzrlib.lockdir import LockDir [as 别名]
# 或者: from bzrlib.lockdir.LockDir import unlock [as 别名]
    def test_50_lockdir_representation(self):
        """Check the on-disk representation of LockDirs is as expected.

        There should always be a top-level directory named by the lock.
        When the lock is held, there should be a lockname/held directory
        containing an info file.
        """
        t = self.get_transport()
        lf1 = LockDir(t, 'test_lock')
        lf1.create()
        self.assertTrue(t.has('test_lock'))
        lf1.lock_write()
        self.assertTrue(t.has('test_lock/held/info'))
        lf1.unlock()
        self.assertFalse(t.has('test_lock/held/info'))
开发者ID:GymWenFLL,项目名称:tpp_libs,代码行数:17,代码来源:test_lockdir.py

示例7: test_31_lock_wait_easy

# 需要导入模块: from bzrlib.lockdir import LockDir [as 别名]
# 或者: from bzrlib.lockdir.LockDir import unlock [as 别名]
 def test_31_lock_wait_easy(self):
     """Succeed when waiting on a lock with no contention.
     """
     t = self.get_transport()
     lf1 = LockDir(t, 'test_lock')
     lf1.create()
     self.setup_log_reporter(lf1)
     try:
         before = time.time()
         lf1.wait_lock(timeout=0.4, poll=0.1)
         after = time.time()
         self.assertTrue(after - before <= 1.0)
     finally:
         lf1.unlock()
     self.assertEqual([], self._logged_reports)
开发者ID:GymWenFLL,项目名称:tpp_libs,代码行数:17,代码来源:test_lockdir.py

示例8: test_44_break_already_released

# 需要导入模块: from bzrlib.lockdir import LockDir [as 别名]
# 或者: from bzrlib.lockdir.LockDir import unlock [as 别名]
 def test_44_break_already_released(self):
     """Lock break races with regular release"""
     t = self.get_transport()
     lf1 = LockDir(t, 'test_lock')
     lf1.create()
     lf1.attempt_lock()
     # someone else sees it's still locked
     lf2 = LockDir(t, 'test_lock')
     holder_info = lf2.peek()
     # in the interim the lock is released
     lf1.unlock()
     # break should succeed
     lf2.force_break(holder_info)
     # now we should be able to take it
     lf2.attempt_lock()
     lf2.confirm()
开发者ID:c0ns0le,项目名称:cygwin,代码行数:18,代码来源:test_lockdir.py

示例9: test_45_break_mismatch

# 需要导入模块: from bzrlib.lockdir import LockDir [as 别名]
# 或者: from bzrlib.lockdir.LockDir import unlock [as 别名]
 def test_45_break_mismatch(self):
     """Lock break races with someone else acquiring it"""
     t = self.get_transport()
     lf1 = LockDir(t, 'test_lock')
     lf1.create()
     lf1.attempt_lock()
     # someone else sees it's still locked
     lf2 = LockDir(t, 'test_lock')
     holder_info = lf2.peek()
     # in the interim the lock is released
     lf1.unlock()
     lf3 = LockDir(t, 'test_lock')
     lf3.attempt_lock()
     # break should now *fail*
     self.assertRaises(LockBreakMismatch, lf2.force_break,
                       holder_info)
     lf3.unlock()
开发者ID:GymWenFLL,项目名称:tpp_libs,代码行数:19,代码来源:test_lockdir.py

示例10: test_30_lock_wait_fail

# 需要导入模块: from bzrlib.lockdir import LockDir [as 别名]
# 或者: from bzrlib.lockdir.LockDir import unlock [as 别名]
 def test_30_lock_wait_fail(self):
     """Wait on a lock, then fail
     
     We ask to wait up to 400ms; this should fail within at most one
     second.  (Longer times are more realistic but we don't want the test
     suite to take too long, and this should do for now.)
     """
     t = self.get_transport()
     lf1 = LockDir(t, 'test_lock')
     lf1.create()
     lf2 = LockDir(t, 'test_lock')
     self.setup_log_reporter(lf2)
     lf1.attempt_lock()
     try:
         before = time.time()
         self.assertRaises(LockContention, lf2.wait_lock,
                           timeout=0.4, poll=0.1)
         after = time.time()
         # it should only take about 0.4 seconds, but we allow more time in
         # case the machine is heavily loaded
         self.assertTrue(after - before <= 8.0, 
                 "took %f seconds to detect lock contention" % (after - before))
     finally:
         lf1.unlock()
     lock_base = lf2.transport.abspath(lf2.path)
     self.assertEqual(1, len(self._logged_reports))
     lock_url = lf2.transport.abspath(lf2.path)
     self.assertEqual('%s %s\n'
                      '%s\n%s\n'
                      'Will continue to try until %s, unless '
                      'you press Ctrl-C\n'
                      'If you\'re sure that it\'s not being '
                      'modified, use bzr break-lock %s',
                      self._logged_reports[0][0])
     args = self._logged_reports[0][1]
     self.assertEqual('Unable to obtain', args[0])
     self.assertEqual('lock %s' % (lock_base,), args[1])
     self.assertStartsWith(args[2], 'held by ')
     self.assertStartsWith(args[3], 'locked ')
     self.assertEndsWith(args[3], ' ago')
     self.assertContainsRe(args[4], r'\d\d:\d\d:\d\d')
开发者ID:c0ns0le,项目名称:cygwin,代码行数:43,代码来源:test_lockdir.py

示例11: test_auto_break_stale_lock

# 需要导入模块: from bzrlib.lockdir import LockDir [as 别名]
# 或者: from bzrlib.lockdir.LockDir import unlock [as 别名]
    def test_auto_break_stale_lock(self):
        """Locks safely known to be stale are just cleaned up.

        This generates a warning but no other user interaction.
        """
        self.overrideAttr(lockdir, 'get_host_name',
            lambda: 'aproperhostname')
        # This is off by default at present; see the discussion in the bug.
        # If you change the default, don't forget to update the docs.
        config.GlobalConfig().set_user_option('locks.steal_dead', True)
        # Create a lock pretending to come from a different nonexistent
        # process on the same machine.
        l1 = LockDir(self.get_transport(), 'a',
            extra_holder_info={'pid': '12312313'})
        token_1 = l1.attempt_lock()
        l2 = LockDir(self.get_transport(), 'a')
        token_2 = l2.attempt_lock()
        # l1 will notice its lock was stolen.
        self.assertRaises(errors.LockBroken,
            l1.unlock)
        l2.unlock()
开发者ID:GymWenFLL,项目名称:tpp_libs,代码行数:23,代码来源:test_lockdir.py

示例12: test_create_missing_base_directory

# 需要导入模块: from bzrlib.lockdir import LockDir [as 别名]
# 或者: from bzrlib.lockdir.LockDir import unlock [as 别名]
    def test_create_missing_base_directory(self):
        """If LockDir.path doesn't exist, it can be created

        Some people manually remove the entire lock/ directory trying
        to unlock a stuck repository/branch/etc. Rather than failing
        after that, just create the lock directory when needed.
        """
        t = self.get_transport()
        lf1 = LockDir(t, 'test_lock')

        lf1.create()
        self.assertTrue(t.has('test_lock'))

        t.rmdir('test_lock')
        self.assertFalse(t.has('test_lock'))

        # This will create 'test_lock' if it needs to
        lf1.lock_write()
        self.assertTrue(t.has('test_lock'))
        self.assertTrue(t.has('test_lock/held/info'))

        lf1.unlock()
        self.assertFalse(t.has('test_lock/held/info'))
开发者ID:GymWenFLL,项目名称:tpp_libs,代码行数:25,代码来源:test_lockdir.py

示例13: test_46_fake_read_lock

# 需要导入模块: from bzrlib.lockdir import LockDir [as 别名]
# 或者: from bzrlib.lockdir.LockDir import unlock [as 别名]
 def test_46_fake_read_lock(self):
     t = self.get_transport()
     lf1 = LockDir(t, 'test_lock')
     lf1.create()
     lf1.lock_read()
     lf1.unlock()
开发者ID:GymWenFLL,项目名称:tpp_libs,代码行数:8,代码来源:test_lockdir.py


注:本文中的bzrlib.lockdir.LockDir.unlock方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。