This repository was archived by the owner on Nov 23, 2023. It is now read-only.

Description
e.g.
def repeat(_time):
# close the decorator over time argument
def decorator(f):
# define the coroutine
async def g():
# call `f` every `time` seconds
while True:
t1 = time.time()
f()
t2 = time.time()
delta_t = t2 - t1
sleep_time = _time-delta_t
if (sleep_time < 0):
print("Warning: repeat@ sleep time < 0")
await asyncio.sleep(0)
else:
await asyncio.sleep(sleep_time)
# track the coroutine in a global list
_loop_fns.append(g)
return decorator