Skip to content

feat: add a concurrency limit for named child runs - #1154

Draft
vdusek wants to merge 7 commits into
feat/abort-child-runs-with-parentfrom
feat/child-run-concurrency-limit
Draft

vdusek wants to merge 7 commits into
feat/abort-child-runs-with-parentfrom
feat/child-run-concurrency-limit

Conversation

@vdusek

@vdusek vdusek commented Sep 30, 2026

Copy link
Copy Markdown
Contributor

Stacked on #1153.

Adds Actor.set_child_run_limits(max_concurrent_runs=...). While that many named child runs are READY, RUNNING, ABORTING or TIMING-OUT, a named Actor.start or Actor.call that would start or resurrect a run waits for one of them to finish. Reattaching to a recorded run never waits, and runs without a name aren't counted.

The count comes from the child run registry, so children started before a migration hold their slots too. A child's status is fetched again before counting once it's more than 10 seconds old, so a finished run nobody waited on frees its slot. Actor.call frees the slot as soon as its run finishes. A start holds its slot until the run is recorded, which keeps concurrent starts under different names within the limit.

The limit lives in memory, so the Actor sets it again after a migration. Once the parent receives ABORTING, a start still waiting for a slot raises a RuntimeError without starting a run. Waiting further would block the abort of the other children.

Closes #1138

✍️ Drafted by Claude Code

@vdusek vdusek added the t-tooling Issues with this label are in the ownership of the tooling team. label Sep 30, 2026
@vdusek vdusek self-assigned this Sep 30, 2026
@vdusek
vdusek added this pull request to stack #1152 September 30, 2026 09:49
@codecov

codecov Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.50000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 93.29%. Comparing base (9554a97) to head (5bbadc2).

Files with missing lines Patch % Lines
src/apify/_child_runs.py 97.36% 2 Missing ⚠️
Additional details and impacted files
@@                          Coverage Diff                          @@
##           feat/abort-child-runs-with-parent    #1154      +/-   ##
=====================================================================
+ Coverage                              93.21%   93.29%   +0.08%     
=====================================================================
  Files                                     54       54              
  Lines                                   3728     3804      +76     
=====================================================================
+ Hits                                    3475     3549      +74     
- Misses                                   253      255       +2     
Flag Coverage Δ
e2e 32.86% <23.75%> (-0.17%) ⬇️
integration 52.05% <23.75%> (-0.56%) ⬇️
unit 90.14% <97.50%> (+0.14%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

t-tooling Issues with this label are in the ownership of the tooling team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Limit the number of concurrent child runs

2 participants