Files
hatchet/sdks/python/examples/priority/worker.py
Matt Kaye 94d06a643c [Python] Fix: Task defaults, Patching fixes, Datetime conversions (#1667)
* feat: start wiring up defaults

* feat: add test coverage

* fix: test docs

* feat: expand tests

* fix: rm validators for now

* chore: minor version

* fix: skip prio tests in ci for now

* chore: docs

* debug: attempt to fix prio test by running with a single slot and no concurrency

* fix: python script to apply patches

* chore; gen

* feat: atomic patches

* fix: rm sed-based patches

* fix: use current tz

* fix: ordering
2025-05-06 17:31:36 -04:00

36 lines
624 B
Python

import time
from hatchet_sdk import Context, EmptyModel, Hatchet
hatchet = Hatchet(debug=True)
# > Default priority
DEFAULT_PRIORITY = 1
SLEEP_TIME = 0.25
priority_workflow = hatchet.workflow(
name="PriorityWorkflow",
default_priority=DEFAULT_PRIORITY,
)
# !!
@priority_workflow.task()
def priority_task(input: EmptyModel, ctx: Context) -> None:
print("Priority:", ctx.priority)
time.sleep(SLEEP_TIME)
def main() -> None:
worker = hatchet.worker(
"priority-worker",
slots=1,
workflows=[priority_workflow],
)
worker.start()
if __name__ == "__main__":
main()