File: hot_datetime.py

package info (click to toggle)
python-rx 4.0.4-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,056 kB
  • sloc: python: 39,070; javascript: 77; makefile: 24
file content (22 lines) | stat: -rw-r--r-- 465 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.utcnow()
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()