本文整理汇总了Python中rx.core.Observable.throw方法的典型用法代码示例。如果您正苦于以下问题:Python Observable.throw方法的具体用法?Python Observable.throw怎么用?Python Observable.throw使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rx.core.Observable
的用法示例。
在下文中一共展示了Observable.throw方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: go
# 需要导入模块: from rx.core import Observable [as 别名]
# 或者: from rx.core.Observable import throw [as 别名]
async def go():
nonlocal result
source = Observable.throw(error)
try:
result = await source
except Exception as ex:
result = ex
示例2: start_async
# 需要导入模块: from rx.core import Observable [as 别名]
# 或者: from rx.core.Observable import throw [as 别名]
def start_async(cls, function_async):
"""Invokes the asynchronous function, surfacing the result through an
observable sequence.
Keyword arguments:
:param types.FunctionType function_async: Asynchronous function which
returns a Future to run.
:returns: An observable sequence exposing the function's result value, or an
exception.
:rtype: Observable
"""
try:
future = function_async()
except Exception as ex:
return Observable.throw(ex)
return Observable.from_future(future)
示例3: test_for_each_index_throws
# 需要导入模块: from rx.core import Observable [as 别名]
# 或者: from rx.core.Observable import throw [as 别名]
def test_for_each_index_throws(self):
ex = Exception()
xs = Observable.throw(ex)
self.assertRaises(Exception, lambda:xs.to_blocking().for_each(lambda x, i: _raise(ex)))