本文整理汇总了Python中rx.observable.Observable.throw方法的典型用法代码示例。如果您正苦于以下问题:Python Observable.throw方法的具体用法?Python Observable.throw怎么用?Python Observable.throw使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rx.observable.Observable
的用法示例。
在下文中一共展示了Observable.throw方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: timeoutAbsolute
# 需要导入模块: from rx.observable import Observable [as 别名]
# 或者: from rx.observable.Observable import throw [as 别名]
def timeoutAbsolute(self, dueTime, other=None, scheduler=Scheduler.timeBasedOperation):
assert isinstance(self, Observable)
assert isinstance(scheduler, Scheduler)
if other == None:
other = Observable.throw(TimeoutException())
assert isinstance(other, Observable)
return TimeoutAbsolute(self, dueTime, other, scheduler)
示例2: timeoutIndividual
# 需要导入模块: from rx.observable import Observable [as 别名]
# 或者: from rx.observable.Observable import throw [as 别名]
def timeoutIndividual(self, durationSelector, firstTimeout=None, other=None):
assert isinstance(self, Observable)
if firstTimeout == None:
firstTimeout = Observable.never()
if other == None:
other = Observable.throw(TimeoutException())
assert isinstance(firstTimeout, Observable)
assert isinstance(other, Observable)
return TimeoutObservable(self, firstTimeout, durationSelector, other)
示例3: run
# 需要导入模块: from rx.observable import Observable [as 别名]
# 或者: from rx.observable.Observable import throw [as 别名]
def run(self):
source = None
disposable = Disposable.empty()
try:
resource = self.parent.resourceFactory()
if resource != None:
disposable = resource
source = self.parent.observableFactory(resource)
except Exception as e:
return CompositeDisposable(Observable.throw(e).subscribeSafe(self), disposable)
return CompositeDisposable(source.subscribeSafe(self), disposable)
示例4: start_async
# 需要导入模块: from rx.observable import Observable [as 别名]
# 或者: from rx.observable.Observable import throw [as 别名]
def start_async(cls, function_async):
"""Invokes the asynchronous function, surfacing the result through an
observable sequence.
Keyword arguments:
function_async -- {Function} Asynchronous function which returns a
Future to run.
Returns {Observable} An observable sequence exposing the function's
result value, or an exception."""
try:
future = function_async()
except Exception as ex:
return Observable.throw(ex)
return Observable.from_future(future)