本文整理匯總了Python中Interrupt.checkInterrupt方法的典型用法代碼示例。如果您正苦於以下問題:Python Interrupt.checkInterrupt方法的具體用法?Python Interrupt.checkInterrupt怎麽用?Python Interrupt.checkInterrupt使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Interrupt
的用法示例。
在下文中一共展示了Interrupt.checkInterrupt方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _waitForCheck
# 需要導入模塊: import Interrupt [as 別名]
# 或者: from Interrupt import checkInterrupt [as 別名]
def _waitForCheck(self, cond, res_check, timeout):
deadline = time.time() + timeout
res = None
while time.time() < deadline:
Interrupt.checkInterrupt()
res = cond()
if res_check(res):
return [True, res]
time.sleep(0.03)
return [False, res]
示例2: waitForSub
# 需要導入模塊: import Interrupt [as 別名]
# 或者: from Interrupt import checkInterrupt [as 別名]
def waitForSub(self, name, root, accept=None, timeout=10, remove=True):
client = self.getClient()
def default_accept(dat):
return True
if accept is None:
accept = default_accept
deadline = time.time() + timeout
while time.time() < deadline:
Interrupt.checkInterrupt()
sub = self.getSubscription(name, root=root, remove=False)
if sub is not None:
res = accept(sub)
if res:
return self.getSubscription(name, root=root, remove=remove)
# wait for more data
client.setTimeout(deadline - time.time())
client.receive()
return None