Skip to content

feat(autoscaling)!: Make AutoscaledPool.pause() async and wait for running tasks - #2365

Merged
vdusek merged 3 commits into
apify:v2from
Mantisus:pause-pool
Nov 3, 2026
Merged

vdusek merged 3 commits into
apify:v2from
Mantisus:pause-pool

Conversation

@Mantisus

Copy link
Copy Markdown
Collaborator

Description

AutoscaledPool.pause() is now a coroutine that returns once the pool's tasks in progress finish, like pause() in Crawlee JS. With the new timeout option, it raises TimeoutError if they take longer, and the pool stays paused. Nothing in Crawlee calls it yet. The crawler's pause() and resume() and pausing on migration need the per-run state from #2301. The upgrade guide covers the change.

Where Crawlee JS doesn't keep the contract its pause() documents, this PR keeps it. A repeated pause() also waits for the tasks in progress. A pause() that comes while the pool awaits is_task_ready_function or is_finished_function doesn't let a new task start or run() return.

✍️ Drafted by Claude Code

@Mantisus Mantisus self-assigned this Oct 29, 2026
@github-actions github-actions Bot added the t-tooling Issues with this label are in the ownership of the tooling team. label Oct 29, 2026
@Mantisus
Mantisus requested review from Pijukatel and vdusek October 29, 2026 23:48

@vdusek vdusek left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, only one nit.

@vdusek vdusek changed the title feat(autoscaling)!: Make AutoscaledPool.pause() wait for the running tasks feat(autoscaling)!: Make AutoscaledPool.pause() wait for running tasks Nov 2, 2026
@vdusek vdusek changed the title feat(autoscaling)!: Make AutoscaledPool.pause() wait for running tasks feat(autoscaling)!: Make AutoscaledPool.pause() async and wait for running tasks Nov 3, 2026
@vdusek
vdusek merged commit 1bff4e3 into apify:v2 Nov 3, 2026
35 checks passed
vdusek pushed a commit that referenced this pull request Nov 5, 2026
…running tasks (#2365)

### Description

`AutoscaledPool.pause()` is now a coroutine that returns once the pool's
tasks in progress finish, like `pause()` in Crawlee JS. With the new
`timeout` option, it raises `TimeoutError` if they take longer, and the
pool stays paused. Nothing in Crawlee calls it yet. The crawler's
`pause()` and `resume()` and pausing on migration need the per-run state
from #2301. The upgrade guide covers the change.

Where Crawlee JS doesn't keep the contract its `pause()` documents, this
PR keeps it. A repeated `pause()` also waits for the tasks in progress.
A `pause()` that comes while the pool awaits `is_task_ready_function` or
`is_finished_function` doesn't let a new task start or `run()` return.

*✍️ Drafted by Claude Code*
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.

2 participants