Files
hatchet/sdks/python/examples/durable_sleep/worker.py
abelanger5 9c1e6ecf2b docs: durable execution + update self-hosted defaults to use v1 (#1484)
* docs: update self-hosted defaults to use v1

* docs: durable execution

* rm dep

* lint: run black

* redundant readme

* more wording

* other small things

* isort
2025-04-03 11:29:59 -04:00

26 lines
528 B
Python

from datetime import timedelta
from hatchet_sdk import DurableContext, EmptyModel, Hatchet
hatchet = Hatchet(debug=True)
# ❓ Durable Sleep
@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)
# !!
def main() -> None:
worker = hatchet.worker("durable-sleep-worker", workflows=[durable_sleep_task])
worker.start()
if __name__ == "__main__":
main()