当前位置: 首页>>代码示例>>Python>>正文


Python Observable.timer方法代码示例

本文整理汇总了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)
开发者ID:alexcwyu,项目名称:python-trading,代码行数:12,代码来源:bar_aggregator.py

示例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)
开发者ID:Reactive-Extensions,项目名称:RxPy,代码行数:19,代码来源:observable_time.py

示例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()
开发者ID:geowa4,项目名称:python3-docker-pex-rxpy-asyncio-experiments,代码行数:21,代码来源:__init__.py


注:本文中的rx.observable.Observable.timer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。