This repository was archived by the owner on Oct 15, 2026. It is now read-only.
Repository navigation
fix(cache): allow nested and recursive cached calls - #3077
Open
AgiKukudala wants to merge 1 commit into
Open
AgiKukudala wants to merge 1 commit into
AgiKukudala wants to merge 1 commit into
Conversation
Co-Authored-By: OpenAI Codex <noreply@openai.com>
This branch has not been deployed
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Calling a cached resource loader from another cached loader currently deadlocks: the outer call holds the global non-reentrant lock and the inner call tries to acquire it again on the same thread. Recursive cached functions also hang.
Use a reentrant lock so these calls complete while retaining the existing synchronization and single-computation behavior for concurrent callers. The regression exercises nested loaders, cache hits and recursive Fibonacci in a subprocess with a timeout, so a recurrence cannot hang the test runner. It times out on unchanged code and passes with the fix.
Validation: 54 cache, chat-context and user-session tests passed on Python 3.13, including the existing concurrent cache test. Ruff lint/format checks and
git diff --checkpassed. One existing third-party Pydantic deprecation warning remains.Prepared with assistance from OpenAI Codex; the diff was reviewed and the checks above were run locally.
Summary by cubic
Fixes a deadlock when a cached resource loader calls another cached loader or when a cached function recurses: the outer call held the global non-reentrant lock, so the inner call hung on the same thread. The cache now uses a reentrant lock, so these calls complete while concurrent callers still share a single computation.
Adds a regression test that runs nested loaders, cache hits, and recursive Fibonacci in a subprocess with a timeout, so a deadlock cannot hang the test runner.
Written for commit e6e7a1d. Summary will update on new commits.