mirror of
https://github.com/RYGhub/royalnet.git
synced 2024-11-23 19:44:20 +00:00
Create sleep_until
This commit is contained in:
parent
23594fc4ac
commit
8d0e6d8c5c
1 changed files with 10 additions and 0 deletions
10
royalnet/utils/sleepuntil.py
Normal file
10
royalnet/utils/sleepuntil.py
Normal file
|
@ -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())
|
Loading…
Reference in a new issue