Files
hatchet/sdks/python/examples/non_retryable/worker.py
T
Matt Kaye b3e5630e1a Fix: Move Non-Retryable to hatchet_sdk.exceptions (#1483)
* feat: move non-retry to exceptions

* fix: client config default

* chore: ver

* cleanup: fix some dependencies

* feat: add retries to pytest in CI
2025-04-03 09:00:18 -04:00

36 lines
917 B
Python

from hatchet_sdk import Context, EmptyModel, Hatchet
from hatchet_sdk.exceptions import NonRetryableException
hatchet = Hatchet(debug=True)
non_retryable_workflow = hatchet.workflow(name="NonRetryableWorkflow")
# ❓ Non-retryable task
@non_retryable_workflow.task(retries=1)
def should_not_retry(input: EmptyModel, ctx: Context) -> None:
raise NonRetryableException("This task should not retry")
# !!
@non_retryable_workflow.task(retries=1)
def should_retry_wrong_exception_type(input: EmptyModel, ctx: Context) -> None:
raise TypeError("This task should retry because it's not a NonRetryableException")
@non_retryable_workflow.task(retries=1)
def should_not_retry_successful_task(input: EmptyModel, ctx: Context) -> None:
pass
def main() -> None:
worker = hatchet.worker("non-retry-worker", workflows=[non_retryable_workflow])
worker.start()
if __name__ == "__main__":
main()