當前位置: 首頁>>代碼示例>>Python>>正文


Python Promise.isCancelRequested方法代碼示例

本文整理匯總了Python中qi.Promise.isCancelRequested方法的典型用法代碼示例。如果您正苦於以下問題:Python Promise.isCancelRequested方法的具體用法?Python Promise.isCancelRequested怎麽用?Python Promise.isCancelRequested使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在qi.Promise的用法示例。


在下文中一共展示了Promise.isCancelRequested方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_future_unwrap_cancel

# 需要導入模塊: from qi import Promise [as 別名]
# 或者: from qi.Promise import isCancelRequested [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()
開發者ID:aldebaran,項目名稱:libqi-python,代碼行數:16,代碼來源:test_promise.py

示例2: test_future_andthen_cancel

# 需要導入模塊: from qi import Promise [as 別名]
# 或者: from qi.Promise import isCancelRequested [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
開發者ID:aldebaran,項目名稱:libqi-python,代碼行數:22,代碼來源:test_promise.py

示例3: test_future_cancel_request

# 需要導入模塊: from qi import Promise [as 別名]
# 或者: from qi.Promise import isCancelRequested [as 別名]
def test_future_cancel_request():
    promise = Promise()
    future = promise.future()
    future.cancel()
    assert promise.isCancelRequested()
開發者ID:aldebaran,項目名稱:libqi-python,代碼行數:7,代碼來源:test_promise.py


注:本文中的qi.Promise.isCancelRequested方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。