mirror of
https://github.com/hatchet-dev/hatchet.git
synced 2025-12-31 05:39:41 -06:00
* feat: timeout on python steps * chore(python-sdk): improved thread handling and docs * docs: default timeout
27 lines
651 B
Python
27 lines
651 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_threads=4)
|
|
worker.register_workflow(workflow)
|
|
|
|
worker.start() |