Open chriso opened 7 months ago
I was looking at sleep and found this issue. Now that we are integrated with asyncio, I'm guessing we should somehow integrate with asyncio.sleep.
However I'm wondering if we should implement that in the Ring side to provide durable sleeps.
The local coroutine scheduler (#52) interacts with Dispatch by polling with zero or more calls. Another capability of
poll
is the ability to delay resumption of the coroutine(s) (usingmax_wait
).The scheduler could provide a
sleep(duration)
directive – alongside the existingcall
andgather
directives – that puts a coroutine to sleep for the specified duration.This could obviously be used to delay work. It could also be used with https://github.com/stealthrocket/dispatch-sdk-python/issues/88 to implement higher-level concurrency patterns. For example,
await any(sleep(0), someOperation())
could be used to submit a fire-and-forget operation without blocking the coroutine, allowing it to continue on with additional work.