Skip to content

fix(dispatcher): clean up closed stream tasks#2072

Open
reallav0 wants to merge 1 commit into
unclecode:developfrom
reallav0:agent/cancel-streaming-dispatch-tasks
Open

fix(dispatcher): clean up closed stream tasks#2072
reallav0 wants to merge 1 commit into
unclecode:developfrom
reallav0:agent/cancel-streaming-dispatch-tasks

Conversation

@reallav0

Copy link
Copy Markdown

Summary

  • cancel and await active crawl tasks when a MemoryAdaptiveDispatcher stream closes
  • discard URLs queued by the closed stream before the dispatcher can be reused
  • await memory-monitor cancellation and add a deterministic regression test

Root cause

run_urls_stream() created per-URL tasks but its finally block only cancelled the memory monitor. Closing or cancelling the generator therefore left active crawls and queued URLs owned by the old stream alive, allowing them to overlap a later crawl on the same dispatcher and browser.

Fixes #2071.

Validation

  • dependency-light async regression harness covering active-task cancellation, queue cleanup, session-count restoration, and absence of background tasks
  • python -m py_compile crawl4ai/async_dispatcher.py tests/async/test_dispatchers.py
  • git diff --check

Focused pytest was not run because pytest and the project runtime dependencies are not installed in this workspace.

@reallav0 reallav0 marked this pull request as ready for review July 12, 2026 16:30
@reallav0

Copy link
Copy Markdown
Author

check failed cause no one put the discord webhook in the env

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant