本文整理汇总了Python中_emerge.AsynchronousLock.AsynchronousLock.cancel方法的典型用法代码示例。如果您正苦于以下问题:Python AsynchronousLock.cancel方法的具体用法?Python AsynchronousLock.cancel怎么用?Python AsynchronousLock.cancel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类_emerge.AsynchronousLock.AsynchronousLock
的用法示例。
在下文中一共展示了AsynchronousLock.cancel方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _testAsynchronousLockWaitCancel
# 需要导入模块: from _emerge.AsynchronousLock import AsynchronousLock [as 别名]
# 或者: from _emerge.AsynchronousLock.AsynchronousLock import cancel [as 别名]
def _testAsynchronousLockWaitCancel(self):
scheduler = global_event_loop()
tempdir = tempfile.mkdtemp()
try:
path = os.path.join(tempdir, 'lock_me')
lock1 = AsynchronousLock(path=path, scheduler=scheduler)
lock1.start()
self.assertEqual(lock1.wait(), os.EX_OK)
self.assertEqual(lock1.returncode, os.EX_OK)
lock2 = AsynchronousLock(path=path, scheduler=scheduler,
_force_async=True, _force_process=True)
lock2.start()
# lock2 should be waiting for lock1 to release
self.assertEqual(lock2.poll(), None)
self.assertEqual(lock2.returncode, None)
# Cancel lock2 and then check wait() and returncode results.
lock2.cancel()
self.assertEqual(lock2.wait() == os.EX_OK, False)
self.assertEqual(lock2.returncode == os.EX_OK, False)
self.assertEqual(lock2.returncode is None, False)
lock1.unlock()
finally:
shutil.rmtree(tempdir)