Delay

Definition

class broqer.op.Delay(duration: float, error_callback=<broqer.default_error_handler.DefaultErrorHandler object>, loop=None)[source]

Emit every value delayed by the given time.

Parameters:
  • duration – time of delay in seconds
  • error_callback – the error callback to be registered
  • loop – asyncio event loop to use

Usage

Emit every value delayed by the given time.

Usage:

>>> import asyncio
>>> from broqer import Subject, op
>>> s = Subject()
>>> s | op.Delay(0.1) | op.Sink(print)
<...>
>>> s.emit(1)
>>> s.emit(2)
>>> asyncio.get_event_loop().run_until_complete(asyncio.sleep(0.05))
>>> s.emit(3)
>>> asyncio.get_event_loop().run_until_complete(asyncio.sleep(0.07))
1
2
>>> asyncio.get_event_loop().run_until_complete(asyncio.sleep(0.05))
3