We use cookies

We use cookies and similar technologies for analytics and marketing. You can allow these cookies or continue with only essential cookies.

By clicking "Accept", you agree to our use of cookies.
Learn more.

Durable Sleep

A durable task can elect to sleep for either a specified period of time or until a provided time, which pauses task execution. While the task is sleeping, no resources are consumed, and the task can also be evicted in order to free the worker slot.

Unlike a language-level sleep (e.g. time.sleep in Python or setTimeout in Node), durable sleep is guaranteed to respect the original duration across interruptions of the durable task, worker crashes, and so on. A language-level sleep ties the wait to the local process, so if the process restarts, the sleep starts over from scratch.

Using durable sleep

The DurableContext exposes helper methods to allow you to sleep for either a specific duration of time, or until a certain time.

@hatchet.durable_task(name="DurableSleepTask")async def durable_sleep_task(input: EmptyModel, ctx: DurableContext) -> None:    res = await ctx.aio_sleep_for(timedelta(seconds=5))    print("got result", res)

Last updated on August 11, 2026

On this page