Skip to content

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

Merged
ntohidi merged 1 commit into
unclecode:developfrom
reallav0:agent/cancel-streaming-dispatch-tasks
Jul 14, 2026
Merged

fix(dispatcher): clean up closed stream tasks#2072
ntohidi merged 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

@ntohidi ntohidi merged commit 935f591 into unclecode:develop Jul 14, 2026
1 check failed
@ntohidi

ntohidi commented Jul 14, 2026

Copy link
Copy Markdown
Collaborator

@reallav0 Thanks for your contribution :)

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.

2 participants