dispatch-py icon indicating copy to clipboard operation
dispatch-py copied to clipboard

Sleep directive

Open chriso opened this issue 1 year ago • 1 comments

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) (using max_wait).

The scheduler could provide a sleep(duration) directive – alongside the existing call and gather 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.

chriso avatar Feb 23 '24 23:02 chriso

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.

Pryz avatar Jun 26 '24 18:06 Pryz