-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: exp backoff * chore: lint * bump version and add poetry script
- Loading branch information
1 parent
bc5cacb
commit e504fda
Showing
9 changed files
with
219 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
from hatchet_sdk import Context, Hatchet | ||
|
||
hatchet = Hatchet(debug=True) | ||
|
||
|
||
# ❓ Backoff | ||
@hatchet.workflow() | ||
class BackoffWorkflow: | ||
# 👀 Backoff configuration | ||
@hatchet.step( | ||
retries=10, | ||
# 👀 Maximum number of seconds to wait between retries | ||
backoff_max_seconds=60, | ||
# 👀 Factor to increase the wait time between retries. | ||
# This sequence will be 2s, 4s, 8s, 16s, 32s, 60s... due to the maxSeconds limit | ||
backoff_factor=2.0, | ||
) | ||
def step1(self, context: Context): | ||
if context.retry_count() < 3: | ||
raise Exception("step1 failed") | ||
|
||
return {"status": "success"} | ||
|
||
|
||
# ‼️ | ||
|
||
|
||
def main(): | ||
workflow = BackoffWorkflow() | ||
worker = hatchet.worker("backoff-worker", max_runs=4) | ||
worker.register_workflow(workflow) | ||
|
||
worker.start() | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.