Skip to content

fix(crawler): await inner stream aclose in arun_many (#2083) - #2198

Open
Battleplus wants to merge 1 commit into
unclecode:mainfrom
Battleplus:fix/2083-arun-many-cleanup
Open

fix(crawler): await inner stream aclose in arun_many (#2083)#2198
Battleplus wants to merge 1 commit into
unclecode:mainfrom
Battleplus:fix/2083-arun-many-cleanup

Conversation

@Battleplus

Copy link
Copy Markdown

Summary

Fixes #2083 — When the outer result_transformer() generator is closed via aclose(), the inner dispatcher.run_urls_stream() generator was not explicitly closed, so its cleanup could overlap with session teardown.

Fix

Explicitly aclose() the inner generator in the finally block before releasing the session.

Files changed

  • crawl4ai/async_webcrawler.py (+9/-4)

When the outer result_transformer() generator is closed via aclose(),
the inner dispatcher.run_urls_stream() generator was not explicitly
closed, so its cleanup (task cancellation, session release) could
overlap with session teardown.

Explicitly aclose() the inner generator in the finally block before
releasing the session.

Closes 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