Skip to content

fix(autoscaling)!: Call is_finished_function only when AutoscaledPool is idle - #2332

Draft
Mantisus wants to merge 2 commits into
apify:v2from
Mantisus:pool-optimization
Draft

Mantisus wants to merge 2 commits into
apify:v2from
Mantisus:pool-optimization

Conversation

@Mantisus

Copy link
Copy Markdown
Collaborator

Description

AutoscaledPool now calls is_finished_function only when none of its own tasks are running and it can't start a new one, either because no task is ready or because a shared concurrency system has no free capacity. Before, it was called on every loop iteration, even with tasks in flight.

  • Crawlers no longer query the request manager's is_finished() every half second during a crawl, so storage backends get fewer calls.
  • A pool whose is_task_ready_function always resolves to True no longer finishes. It has to resolve to False once the work runs out. The upgrade guide covers this.
  • A paused pool doesn't finish until it's resumed.
  • crawler.stop() now applies only to the current run. A crawler that was stopped once used to end every later run() immediately.
  • After stop() or reaching max_requests_per_crawl, the crawler logs once that it takes no new requests and again when the remaining requests have finished. The stop reason no longer ends with a double period.

Issues

@github-actions github-actions Bot added the t-tooling Issues with this label are in the ownership of the tooling team. label Oct 15, 2026
@Mantisus Mantisus changed the title fix!: call is_finished_function only when AutoscaledPool is idle fix!: Call is_finished_function only when AutoscaledPool is idle Oct 15, 2026
@Mantisus Mantisus self-assigned this Oct 15, 2026
@Mantisus Mantisus changed the title fix!: Call is_finished_function only when AutoscaledPool is idle fix(autoscaling)!: Call is_finished_function only when AutoscaledPool is idle Oct 15, 2026

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.

2 participants