Skip to content

Avoid inverted cache and statistics lock order - #47

Open
fhgffy wants to merge 1 commit into
dgilland:masterfrom
fhgffy:fix-stats-lock-order-20261011
Open

fhgffy wants to merge 1 commit into
dgilland:masterfrom
fhgffy:fix-stats-lock-order-20261011

Conversation

@fhgffy

@fhgffy fhgffy commented Oct 10, 2026

Copy link
Copy Markdown

CacheStatsTracker.info() held the statistics lock while asking the cache for its length. Cache operations hold the cache lock before updating statistics, so a concurrent snapshot and get() could wait on each other indefinitely.

Read the entry count before taking the statistics lock. The regression coordinates the competing operations and bounds the test's lock waits so the failing case cannot leave hanging threads. It fails on the original code and passes with the new order.

Validation on Windows: all 118 tests and doctests pass with 100% source coverage on every supported Python version (3.10, 3.11, 3.12, 3.13, and 3.14). Ruff formatting/lint, mypy, the warning-as-error documentation build, wheel/sdist build, and twine check pass on Python 3.12.

@coveralls

Copy link
Copy Markdown

Coverage Status

coverage: 100.0%. remained the same — fhgffy:fix-stats-lock-order-20261011 into dgilland:master

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