You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 3dd8ca5
Browse filesBrowse the repository at this point in the historyBrowse files
feat: retry starting a run on memory and concurrent-runs limits (#1081)
Adds a `wait_for_resources` argument to `ActorClient.start`/`call` and
`TaskClient.start`/`call`, sync and async. When set, a start that the
API rejects with `actor-memory-limit-exceeded` or
`concurrent-runs-limit-exceeded` is retried every 10 seconds.
Orchestrators no longer need their own wait-and-retry loop.
- `True` retries until the run starts. A `timedelta` limits the
retrying, after which the last 402 error is raised.
- Any other error is raised right away.
- In `call`, the retry time doesn't count toward `wait_duration`.
- A file-like input is read into memory before the first attempt, so
every retry sends it whole.
- A run that asks for more memory than the account's whole memory limit
gets the same `actor-memory-limit-exceeded` error and never starts, so
`True` retries it forever. The API has no separate error type for that
case. The docs call it out.
The Retries concept page gets a section with sync and async examples.
The JS twin is apify/apify-client-js#1091 and uses the same design.
Closes: #1071
*✍️ Drafted by Claude Code*
The Apify client automatically retries requests that fail due to:
17
19
@@ -43,3 +45,27 @@ Retries with exponential backoff help reduce the load on the server and increase
43
45
</CodeBlock>
44
46
</TabItem>
45
47
</Tabs>
48
+
49
+
## Wait for resources to start a run
50
+
51
+
Starting a run fails with an HTTP 402 error when the account doesn't have enough free memory for the run, or when it already runs as many Actors as its plan allows. The error `type` is `actor-memory-limit-exceeded` or `concurrent-runs-limit-exceeded`. The client doesn't retry these errors on its own, since they clear only after other runs or builds of the account finish.
52
+
53
+
To keep retrying the start until the resources free up, set the `wait_for_resources` argument of <ApiLinkto="class/ActorClient#start">`ActorClient.start`</ApiLink>, <ApiLinkto="class/ActorClient#call">`ActorClient.call`</ApiLink>, or the same methods of <ApiLinkto="class/TaskClient">`TaskClient`</ApiLink>. The client then retries the start every 10 seconds, and the argument value sets how long:
54
+
55
+
-`True` retries until the run starts.
56
+
- A `timedelta` stops retrying after that time and raises the last error.
57
+
58
+
Any other error raises right away. A run that asks for more memory than the account's whole memory limit gets the same `actor-memory-limit-exceeded` error and never starts, so with `True` the client retries it forever. In `call`, the time spent retrying doesn't count toward `wait_duration`.
0 commit comments