Skip to content

Preserve cancellation during cached-content reads - #2481

Open
GoldArowana wants to merge 3 commits into
unclecode:developfrom
GoldArowana:mac-pr-deep-20261031-cache-read-cancel
Open

GoldArowana wants to merge 3 commits into
unclecode:developfrom
GoldArowana:mac-pr-deep-20261031-cache-read-cancel

Conversation

@GoldArowana

Copy link
Copy Markdown

Summary

Preserve task cancellation while reading cached content. _load_content() currently catches CancelledError with a bare except, returns None, and lets the cache request continue as though the content were missing. Catching Exception keeps 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 real AsyncDatabaseManager / SQLite cache-path check passes 12 checks, including acache_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

  • Based on and targeting develop.
  • Performed a self-review and added focused regression tests.
  • Focused package tests and real SQLite/cache cleanup checks pass locally.
  • No public API, database schema or documentation changes are required.

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