Repository navigation
Carry the caller's context into render_scene and refresh worker pools (#80) - #85
Merged
Merged
Conversation
…#80) A ThreadPoolExecutor worker does not inherit the submitting thread's contextvars, so a BYO fal key bound with using_fal_credentials was invisible in render_scene's workers and the calls fell back to the operator's env key. Submit each task through its own copy_context().run, as execute_plan does. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…text (#80 review) Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
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.
Fixes #80.
iter_render_scene(concurrency > 1) andrefresh_full_docshanded work to aThreadPoolExecutorwithout copying the caller's context, so a key bound withusing_fal_credentialswas invisible in the workers andrender_scene's fal calls fell back to the operator's env key. Each task is now submitted ascopy_context().run(fn, ...)(one copy per task; a Context cannot be entered by two threads at once), the same asexecute_plan.refresh_full_docsmakes only unauthenticated doc fetches today, so it is a consistency fix there.Tests (fake transport, made-up marker key, no network): a render_scene worker authenticates with the bound key via
SyncClient(key=...)rather than the module-level env path; the refresh pool sees the caller's context. Both fail on main, pass here. Full suite: 707 passed, 1 skipped; ruff clean.Independent review (fresh Opus subagent, tried to break the diff): land it. No defect in the key-carrying fix; no other thread/pool hand-off in falaw loses context (
execute_planalready copies); no key leaks between concurrent callers (copy taken at submit time); the new tests fail on main (checked in a main worktree). One confirmed regression in my first version: swappingpool.mapforsubmitinrefresh_full_docsstopped cancelling pending fetches after the first error (40 of 40 fetched vs 3 of 40). Fixed:pool.mapover per-task context copies. Caveat, not a defect:iter_render_sceneis a generator, so the context is captured at the firstnext(), not at the call.