This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def spawn_after(seconds, function, *args, **kwargs): | |
""" | |
Calls function with args and kwargs after seconds. | |
Runs in background. | |
Function must be a coroutine function. | |
Returns task object which can be cancelled, waited for, etc. | |
Named after Eventlet function https://eventlet.net/doc/modules/greenthread.html#eventlet.greenthread.spawn_after. | |
""" | |
async def task(): | |
await sleep(seconds) |