diff --git a/royalnet/utils/sleepuntil.py b/royalnet/utils/sleepuntil.py new file mode 100644 index 00000000..7b6189cb --- /dev/null +++ b/royalnet/utils/sleepuntil.py @@ -0,0 +1,10 @@ +import asyncio +import datetime + + +async def sleep_until(dt: datetime.datetime): + now = datetime.datetime.now() + if now > dt: + return + delta = dt - now + await asyncio.sleep(delta.total_seconds())