Files
hatchet/python-sdk/examples/logger/worker.py
abelanger5 f256b258d8 feat: logging from step run executions (#217)
* fix: job cancellations with shared ctx

* fix: found the bug

* fix: all job runs were getting cancelled

* feat: support logging from executions

* fix: place logging in background

* add back split screen
2024-03-01 17:55:31 -05:00

25 lines
547 B
Python

import time
from hatchet_sdk import Hatchet, Context
from dotenv import load_dotenv
load_dotenv()
hatchet = Hatchet()
@hatchet.workflow(on_events=["user:create"],schedule_timeout="10m")
class LoggingWorkflow:
@hatchet.step()
def logger(self, context : Context):
for i in range(1000):
context.log(f"Logging message {i}")
return {
"step1": "completed",
}
workflow = LoggingWorkflow()
worker = hatchet.worker('logging-worker-py')
worker.register_workflow(workflow)
worker.start()