本文整理汇总了Python中pulsar.Future.set_exception方法的典型用法代码示例。如果您正苦于以下问题:Python Future.set_exception方法的具体用法?Python Future.set_exception怎么用?Python Future.set_exception使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pulsar.Future
的用法示例。
在下文中一共展示了Future.set_exception方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_ping_pong_monitor
# 需要导入模块: from pulsar import Future [as 别名]
# 或者: from pulsar.Future import set_exception [as 别名]
def test_ping_pong_monitor(self):
value = yield 3
self.assertEqual(value, 3)
try:
future = Future()
future.set_exception(ValueError('test'))
yield future
except ValueError:
pass
pong = yield send('monitor', 'ping')
self.assertEqual(pong, 'pong')
示例2: check_twisted
# 需要导入模块: from pulsar import Future [as 别名]
# 或者: from pulsar.Future import set_exception [as 别名]
def check_twisted(deferred, loop):
"""Binding for twisted.
Added to pulsar asynchronous engine via the :func:`.add_async_binding`
function.
"""
if isinstance(deferred, Deferred):
future = Future(loop=loop)
deferred.addCallbacks(future.set_result, lambda failure: future.set_exception(failure.value))
return future
示例3: _
# 需要导入模块: from pulsar import Future [as 别名]
# 或者: from pulsar.Future import set_exception [as 别名]
def _(*args, **kwargs):
res = callable(*args, **kwargs)
if isinstance(res, types.GeneratorType):
res = _inlineCallbacks(None, res, Deferred())
if isinstance(res, Deferred):
future = Future()
res.addCallbacks(
future.set_result,
lambda failure: future.set_exception(failure.value))
future._deferred = res
return future
else:
raise TypeError(
"Callable %r should return a generator or a twisted Deferred"
% callable)