File: hot_datetime.py

package info (click to toggle)
python-rx 4.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,204 kB
  • sloc: python: 39,525; javascript: 77; makefile: 24
file content (22 lines) | stat: -rw-r--r-- 483 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import datetime

import reactivex
import reactivex.operators as ops

"""
Delay the emission of elements to the specified datetime.
"""

now = datetime.datetime.now(datetime.timezone.utc)
dt = datetime.timedelta(seconds=3.0)
duetime = now + dt

print(
    "{} ->  now\n"
    "{} ->  start of emission in {}s".format(now, duetime, dt.total_seconds())
)

hot = reactivex.hot("10--11--12--13--(14,|)", timespan=0.2, duetime=duetime)

source = hot.pipe(ops.do_action(print))
source.run()