Skip to content

fix(crawler): await dispatcher stream aclose in arun_many#2089

Open
Solaris-star wants to merge 1 commit into
unclecode:mainfrom
Solaris-star:fix/2083-arun-many-stream-aclose
Open

fix(crawler): await dispatcher stream aclose in arun_many#2089
Solaris-star wants to merge 1 commit into
unclecode:mainfrom
Solaris-star:fix/2083-arun-many-stream-aclose

Conversation

@Solaris-star

Copy link
Copy Markdown

Summary

#2072 made MemoryAdaptiveDispatcher.run_urls_stream() clean up when that generator is closed. The public API path AsyncWebCrawler.arun_many(..., stream=True) still only wrapped it in an async for + proxy-session release, so early aclose() on the public generator could release the session while dispatcher-owned tasks were still running.

Change

  • Keep an explicit reference to the dispatcher stream
  • Always await stream_gen.aclose() in finally before proxy-session auto-release

Test plan

  • Existing dispatcher stream-aclose tests (tests/async/test_dispatchers.py) remain the unit-level guarantee for the underlying generator
  • Manual: async for + early generator close on arun_many(..., stream=True) should no longer leave crawl tasks alive

Fixes #2083.

Hold an explicit reference to run_urls_stream and always aclose() it in
the public generator's finally block so dispatcher-owned crawl tasks are
cancelled and awaited before proxy-session release.

Fixes unclecode#2083.
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.

[Bug]: AsyncWebCrawler.arun_many() stream closure does not await dispatcher cleanup in 0.9.2

1 participant