1 2 3 4 5 6 7 8
import time def poll_tick(freq): t = time.time() while True: t += freq yield max(t - time.time(), 0)