fix(orchestrator): lazy threadpool imports for pyodide consumers (sy-2wa)#460
Open
openclaw-dv wants to merge 1 commit into
Open
fix(orchestrator): lazy threadpool imports for pyodide consumers (sy-2wa)#460openclaw-dv wants to merge 1 commit into
openclaw-dv wants to merge 1 commit into
Conversation
…2wa) Move `import threading` + `from concurrent.futures import ThreadPoolExecutor, as_completed` from module top to function-local imports in orchestrator, synthesis, and perturbation. The `synth_panel.ensemble` load chain is now fully threadpool-free at module load time, unblocking Cloudflare Python Workers / pyodide consumers (boardroom DECISION-skill officers) where ThreadPoolExecutor exists as a stub but `.submit()` silently hangs. Adds tests/test_threadpool_lazy_import.py — subprocess-based load-chain hygiene assertions: (1) concurrent.futures stays out of sys.modules after a fresh ensemble import, (2) ensemble loads cleanly under a poisoned concurrent.futures module, (3) ThreadPoolExecutor/as_completed are never bound at the top of orchestrator/synthesis/perturbation. Bumps __version__ to 1.5.0 + refreshes server-card.json / site renders. Co-Authored-By: Claude Opus 4.7 (1M context) <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.
Summary
Moves
import threading+from concurrent.futures import ThreadPoolExecutor, as_completedfrom module top to function-local imports inorchestrator,synthesis, andperturbation. Thesynth_panel.ensembleload chain is nowfully threadpool-free at module load time, unblocking Cloudflare Python
Workers / pyodide consumers (boardroom DECISION-skill officers) where
ThreadPoolExecutorexists as a stub but.submit()silently hangs.Why
pyodide_safe_mode(sy-huo) and thetrafilatura → [full] extramove (sy-v8z)fixed runtime + install-time dep cliffs, but
import synth_panel.ensemblestill pulled
concurrent.futuresat module-load time. Under pyodide theimport succeeds but the executor is a no-op stub — a latent footgun for any
caller that didn't pass
judge_enabled=False/llm_client=.... Thisrelease closes the remaining import-time gap.
Changes
src/synth_panel/orchestrator.py,src/synth_panel/synthesis.py,src/synth_panel/perturbation.py: movethreading+concurrent.futuresimports inside the functions that actually spawn threads.tests/test_threadpool_lazy_import.py: subprocess-based load-chain hygiene assertions —concurrent.futuresstays out ofsys.modulesafter a fresh ensemble import,concurrent.futuresmodule,ThreadPoolExecutor/as_completedare never bound at the top oforchestrator/synthesis/perturbation.server-card.json+ site renders refreshed.Compatibility
No public-API change. Every existing call site keeps working. Pyodide
consumers that were forced into
judge_enabled=Falseto avoid the module-loadcrash can now also use other ensemble entry points safely.
Test plan
tests/test_threadpool_lazy_import.pypins the contract via subprocess + meta-path poisoning.References
pyodide_safe_moderuntime flag), sy-v8z (deps: move trafilatura to optional [full] extra for pyodide compat (sy-v8z) #455, install-time fix), sy-ye1 (feat(cost): surface OpenRouter cost actuals on EnsembleResult / SynthesisResult (sy-ye1) #456, cost actuals)