本文整理汇总了Python中rx.disposable.Disposable.empty方法的典型用法代码示例。如果您正苦于以下问题:Python Disposable.empty方法的具体用法?Python Disposable.empty怎么用?Python Disposable.empty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rx.disposable.Disposable
的用法示例。
在下文中一共展示了Disposable.empty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: invokeRec
# 需要导入模块: from rx.disposable import Disposable [as 别名]
# 或者: from rx.disposable.Disposable import empty [as 别名]
def invokeRec(self, scheduler, state):
time = 0
if self.hasResult:
self.observer.onNext(self.result)
try:
if self.first:
self.first = False
else:
state = self.parent.iterate(state)
self.hasResult = self.parent.condition(state)
if self.hasResult:
self.result = self.parent.resultSelector(state)
time = self.parent.timeSelector(state)
except Exception as e:
self.observer.onError(e)
self.dispose()
return Disposable.empty()
if not self.hasResult:
self.observer.onCompleted()
self.dispose()
return Disposable.empty()
return self.parent.scheduler.scheduleWithRelativeAndState(
state,
time,
self.invokeRec
)
示例2: subscribeCore
# 需要导入模块: from rx.disposable import Disposable [as 别名]
# 或者: from rx.disposable.Disposable import empty [as 别名]
def subscribeCore(self, observer):
old = None
new = None
while True:
old = self.observer.value
if old is DisposedObserver.instance:
raise Exception("Object has been disposed")
if old is DoneObserver.completed:
observer.onCompleted()
return Disposable.empty()
if isinstance(old, DoneObserver):
observer.onError(old.exception)
return Disposable.empty()
if old is NoopObserver.instance:
new = observer
else:
if isinstance(old, ListObserver):
new = old.add(observer)
else:
new = ListObserver((old, observer))
current = self.observer.compareExchange(new, old)
if old is current:
break
return self.Subscription(self, observer)
示例3: subscribeCore
# 需要导入模块: from rx.disposable import Disposable [as 别名]
# 或者: from rx.disposable.Disposable import empty [as 别名]
def subscribeCore(self, observer):
d = self._subscribe(observer)
if d == None:
return Disposable.empty()
else:
return d
示例4: propagate
# 需要导入模块: from rx.disposable import Disposable [as 别名]
# 或者: from rx.disposable.Disposable import empty [as 别名]
def propagate(self, scheduler, currentId):
with self.gate:
if self.hasValue and self.resourceId == currentId:
self.observer.onNext(self.value)
self.hasValue = False
return Disposable.empty()
示例5: connect
# 需要导入模块: from rx.disposable import Disposable [as 别名]
# 或者: from rx.disposable.Disposable import empty [as 别名]
def connect(self, observer):
#
# We connect the given observer to the subject first, before performing any kind
# of initialization which will register an event handler. This is done to ensure
# we don't have a time gap between adding the handler and connecting the user's
# subject, e.g. when the ImmediateScheduler is used.
#
# [OK] Use of unsafe Subscribe: called on a known subject implementation.
#
connection = self.subject.subscribe(observer)
self.count += 1
if self.count == 1:
try:
self.initialize()
except Exception as e:
self.count -= 1
connection.dispose()
observer.onError(e)
return Disposable.empty()
def dispose():
connection.dispose()
with self.parent.gate:
self.count -=1
if self.count == 0:
self.parent.scheduler.schedule(self.removeHandler.dispose)
self.parent.session = None
return Disposable.create(dispose)
示例6: scheduled
# 需要导入模块: from rx.disposable import Disposable [as 别名]
# 或者: from rx.disposable.Disposable import empty [as 别名]
def scheduled(_, message):
# time = message[0]
notification = message[1]
notification.accept(observer)
return Disposable.empty()
示例7: scheduledSubscribe
# 需要导入模块: from rx.disposable import Disposable [as 别名]
# 或者: from rx.disposable.Disposable import empty [as 别名]
def scheduledSubscribe(self, scheduler, autoDetachObserver):
try:
autoDetachObserver.disposable = self.subscribeCore(autoDetachObserver)
except Exception as e:
if not autoDetachObserver.fail(e):
raise e
return Disposable.empty()
示例8: scheduled
# 需要导入模块: from rx.disposable import Disposable [as 别名]
# 或者: from rx.disposable.Disposable import empty [as 别名]
def scheduled():
try:
subject.onNext(action())
subject.onCompleted()
except Exception as e:
subject.onError(e)
return Disposable.empty()
示例9: wrapper
# 需要导入模块: from rx.disposable import Disposable [as 别名]
# 或者: from rx.disposable.Disposable import empty [as 别名]
def wrapper(observer):
a = subscribe(observer)
if isinstance(a, Disposable):
return a
elif callable(a):
return Disposable.create(a)
else:
return Disposable.empty()
示例10: run
# 需要导入模块: from rx.disposable import Disposable [as 别名]
# 或者: from rx.disposable.Disposable import empty [as 别名]
def run(self):
try:
result = self.parent.eval()
except Exception as e:
self.observer.onError(e)
self.dispose()
return Disposable.empty()
else:
return result.subscribeSafe(self)
示例11: schedulerCallback
# 需要导入模块: from rx.disposable import Disposable [as 别名]
# 或者: from rx.disposable.Disposable import empty [as 别名]
def schedulerCallback(self, scheduler, state):
with self.lock:
if self.isAdded:
self.group.remove(self.cancel)
else:
self.isDone = True
self.run(state)
return Disposable.empty()
示例12: timeout
# 需要导入模块: from rx.disposable import Disposable [as 别名]
# 或者: from rx.disposable.Disposable import empty [as 别名]
def timeout(self, scheduler, currentId):
timerWins = False
with self.gate:
self.switched = self.currentId == currentId
timerWins = self.switched
if timerWins:
self.subscription.disposable = self.parent.other.subscribeSafe(self.getForewarder())
return Disposable.empty()
示例13: tick
# 需要导入模块: from rx.disposable import Disposable [as 别名]
# 或者: from rx.disposable.Disposable import empty [as 别名]
def tick(self, scheduler, state):
with self.gate:
if state.isSpan:
s = self.queue.popleft()
s.onCompleted()
if state.isShift:
self.createWindow()
self.createTimer()
return Disposable.empty()
示例14: run
# 需要导入模块: from rx.disposable import Disposable [as 别名]
# 或者: from rx.disposable.Disposable import empty [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)
示例15: subscribeSafe
# 需要导入模块: from rx.disposable import Disposable [as 别名]
# 或者: from rx.disposable.Disposable import empty [as 别名]
def subscribeSafe(self, observer):
if isinstance(self, ObservableBase):
return self.subscribeCore(observer)
elif isinstance(self, Producer):
return self.subscribeRaw(observer, False)
d = Disposable.empty()
try:
d = self.subscribeCore(observer)
except Exception as e:
observer.onError(e)
return d