fix: add retry to runScriptByPathAsync and runScriptByHashAsync (#11485)

* feat: add retry to runScriptByPathAsync and runScriptByHashAsync

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix: refuse retry with invisible_to_owner and keep the parent priority bump

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix: refuse retry when a preprocessor would run and export the options type on jsr

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix: keep the dispatching job as parent of a retried run

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix: cancel pending native retries with their caller and stop the chain on cancel

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
hugocasa
2026-10-08 09:01:32 +02:00
committed by GitHub
co-authored by Claude Opus 5.5
parent 1c2667cd55
commit 3f3b1c2c30
21 changed files with 457 additions and 93 deletions
+21 -4
View File
@@ -196,12 +196,15 @@ class Windmill:
args: dict = None,
scheduled_in_secs: int = None,
tag: str = None,
retry: dict = None,
) -> str:
"""Internal helper for running scripts asynchronously."""
args = args or {}
params = {"scheduled_in_secs": scheduled_in_secs} if scheduled_in_secs else {}
if tag:
params["tag"] = tag
if retry:
params["retry"] = json.dumps(retry)
if os.environ.get("WM_JOB_ID"):
params["parent_job"] = os.environ.get("WM_JOB_ID")
if os.environ.get("WM_ROOT_FLOW_JOB_ID"):
@@ -222,9 +225,15 @@ class Windmill:
args: dict = None,
scheduled_in_secs: int = None,
tag: str = None,
retry: dict = None,
) -> str:
"""Create a script job by path and return its job id."""
return self._run_script_async_internal(path=path, args=args, scheduled_in_secs=scheduled_in_secs, tag=tag)
"""Create a script job by path and return its job id.
``retry`` re-runs the job when it fails, with the policy a schedule takes,
e.g. ``{"constant": {"attempts": 3, "seconds": 10}}``. The returned id is
the first attempt's; each retry is a job of its own, recorded as a child of it.
"""
return self._run_script_async_internal(path=path, args=args, scheduled_in_secs=scheduled_in_secs, tag=tag, retry=retry)
def run_script_by_hash_async(
self,
@@ -232,9 +241,10 @@ class Windmill:
args: dict = None,
scheduled_in_secs: int = None,
tag: str = None,
retry: dict = None,
) -> str:
"""Create a script job by hash and return its job id."""
return self._run_script_async_internal(hash_=hash_, args=args, scheduled_in_secs=scheduled_in_secs, tag=tag)
"""Create a script job by hash and return its job id. See ``run_script_by_path_async`` for ``retry``."""
return self._run_script_async_internal(hash_=hash_, args=args, scheduled_in_secs=scheduled_in_secs, tag=tag, retry=retry)
def run_flow_async(
self,
@@ -1618,6 +1628,7 @@ def run_script_by_path_async(
args: Dict[str, Any] = None,
scheduled_in_secs: Union[None, int] = None,
tag: str = None,
retry: Dict[str, Any] = None,
) -> str:
"""Create a script job by path and return its job ID.
@@ -1626,6 +1637,8 @@ def run_script_by_path_async(
args: Script arguments
scheduled_in_secs: Delay before execution in seconds
tag: Override the worker tag the job runs on
retry: Re-run the job when it fails, with the policy a schedule takes,
e.g. ``{"constant": {"attempts": 3, "seconds": 10}}``
Returns:
Job ID string
@@ -1635,6 +1648,7 @@ def run_script_by_path_async(
args=args,
scheduled_in_secs=scheduled_in_secs,
tag=tag,
retry=retry,
)
@@ -1644,6 +1658,7 @@ def run_script_by_hash_async(
args: Dict[str, Any] = None,
scheduled_in_secs: Union[None, int] = None,
tag: str = None,
retry: Dict[str, Any] = None,
) -> str:
"""Create a script job by hash and return its job ID.
@@ -1652,6 +1667,7 @@ def run_script_by_hash_async(
args: Script arguments
scheduled_in_secs: Delay before execution in seconds
tag: Override the worker tag the job runs on
retry: Re-run the job when it fails, see ``run_script_by_path_async``
Returns:
Job ID string
@@ -1661,6 +1677,7 @@ def run_script_by_hash_async(
args=args,
scheduled_in_secs=scheduled_in_secs,
tag=tag,
retry=retry,
)