Repository navigation
Preserve cancellation during cached-content reads - #2481
Open
GoldArowana wants to merge 3 commits into
Open
GoldArowana wants to merge 3 commits into
GoldArowana wants to merge 3 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Preserve task cancellation while reading cached content.
_load_content()currently catchesCancelledErrorwith a bareexcept, returnsNone, and lets the cache request continue as though the content were missing. CatchingExceptionkeeps ordinary filesystem/decode failures on the existing fallback path while allowing cancellation to propagate through the file and database cleanup.List of files changed and why
crawl4ai/async_database.py: catch ordinary exceptions when loading cached content.tests/unit/test_database_content_cancellation.py: cover real file reads/error fallbacks and cancellation during an established real FIFO read. The POSIX-only cancellation test skips on other platforms.How Has This Been Tested?
On macOS / Python 3.14, the normally imported current package passes both committed regression tests (
2 passed). A separate realAsyncDatabaseManager/ SQLite cache-path check passes 12 checks, includingacache_url/aget_cached_url, cancellation propagation, file and connection cleanup, and reuse of the connection-pool slot. Real file/FIFO controls also pass on Python 3.13 and 3.14.Validation covers the cache-content and database path. The full project suite, browser/model execution, remote websites and Windows were not exercised. This does not make executor-backed filesystem operations interruptible in every phase.
Checklist
develop.