mirror of
https://github.com/hatchet-dev/hatchet.git
synced 2026-01-01 06:11:02 -06:00
* api changes * doc changes * move docs * generated * generate * pkg * backmerge main * revert to main * revert main * race? * remove go tests
35 lines
910 B
Python
35 lines
910 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()
|