本文整理匯總了Python中qi.Promise.setCanceled方法的典型用法代碼示例。如果您正苦於以下問題:Python Promise.setCanceled方法的具體用法?Python Promise.setCanceled怎麽用?Python Promise.setCanceled使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類qi.Promise
的用法示例。
在下文中一共展示了Promise.setCanceled方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_future_unwrap_cancel
# 需要導入模塊: from qi import Promise [as 別名]
# 或者: from qi.Promise import setCanceled [as 別名]
def test_future_unwrap_cancel():
prom = Promise()
future = prom.future().unwrap()
future.cancel()
assert prom.isCancelRequested()
nested = Promise()
prom.setValue(nested.future())
# TODO add some sync-ness to remove those time.sleep :(
time.sleep(0.1)
assert nested.isCancelRequested()
nested.setCanceled()
time.sleep(0.1)
assert future.isCanceled()
示例2: test_future_andthen_cancel
# 需要導入模塊: from qi import Promise [as 別名]
# 或者: from qi.Promise import setCanceled [as 別名]
def test_future_andthen_cancel():
global called
called = False
def callback(v):
global called
called = True
assert False
p = Promise()
f = p.future()
f2 = f.andThen(callback)
f2.cancel()
assert p.isCancelRequested()
p.setCanceled()
f2.wait(1000)
assert f2.isFinished()
assert f2.isCanceled()
time.sleep(0.1)
assert not called