Files
hatchet/python-sdk/examples/timeout/worker.py
abelanger5 6ea38a99f2 feat: support maxRuns parameter on workers (#195)
* feat: round robin queueing

* feat: configurable max runs per worker

* fix: address PR review

* docs for max runs and group round robin
2024-02-26 00:48:46 -05:00

27 lines
648 B
Python

from hatchet_sdk import Hatchet
from dotenv import load_dotenv
load_dotenv()
hatchet = Hatchet(debug=True)
@hatchet.workflow(on_events=["user:create"])
class TimeoutWorkflow:
def __init__(self):
self.my_value = "test"
@hatchet.step(timeout='4s')
def timeout(self, context):
try:
print("started step2")
context.sleep(5)
print("finished step2")
except Exception as e:
print("caught an exception: " + str(e))
raise e
workflow = TimeoutWorkflow()
worker = hatchet.worker('timeout-worker', max_runs=4)
worker.register_workflow(workflow)
worker.start()