本文整理汇总了Python中rx.observable.Observable.timer方法的典型用法代码示例。如果您正苦于以下问题:Python Observable.timer方法的具体用法?Python Observable.timer怎么用?Python Observable.timer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rx.observable.Observable
的用法示例。
在下文中一共展示了Observable.timer方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _start
# 需要导入模块: from rx.observable import Observable [as 别名]
# 或者: from rx.observable.Observable import timer [as 别名]
def _start(self, app_context, **kwargs):
if self.__input is None:
self.__input = app_context.inst_data_mgr.get_series(self.input.name)
self.__input.subject.subscribe(on_next=self.on_update)
if self.__output_bar_type == BarType.Time:
current_ts = self.__clock.now()
next_ts = Bar.get_next_bar_start_time(current_ts, self.__output_size)
diff = next_ts - current_ts
Observable.timer(int(diff), self.__output_size * 1000, self.__clock.scheduler).subscribe(
on_next=self.publish)
示例2: delay_subscription
# 需要导入模块: from rx.observable import Observable [as 别名]
# 或者: from rx.observable.Observable import timer [as 别名]
def delay_subscription(self, duetime, scheduler):
"""Time shifts the observable sequence by delaying the subscription.
1 - res = source.delay_subscription(5000) // 5s
2 - res = source.delay_subscription(5000, Scheduler.timeout) // 5 seconds
duetime -- Absolute or relative time to perform the subscription at.
scheduler [Optional] Scheduler to run the subscription delay timer on.
If not specified, the timeout scheduler is used.
Returns time-shifted sequence.
"""
scheduler = scheduler or timeout_scheduler
def selector(x):
return Observable.empty()
return this.delay_with_selector(Observable.timer(duetime, scheduler), selector)
示例3: run
# 需要导入模块: from rx.observable import Observable [as 别名]
# 或者: from rx.observable.Observable import timer [as 别名]
def run(interval, port):
scheduler = AsyncIOScheduler()
clock = Observable.timer(0, interval, scheduler=scheduler)
loop = asyncio.get_event_loop()
server = TCPServer(loop)
observer = SimpleObserver()
all_events = server.tcp_subject.map(
lambda x: x[0].strip()
).merge(
clock
).debounce(
int(interval / 10),
scheduler=scheduler
)
all_events.subscribe(observer)
server.start(port)
loop.close()