Skip to content

Fix EnvServer executor installation#1455

Merged
xeophon merged 1 commit into
mainfrom
codex/fix-env-server-executor-install
May 25, 2026
Merged

Fix EnvServer executor installation#1455
xeophon merged 1 commit into
mainfrom
codex/fix-env-server-executor-install

Conversation

@xeophon
Copy link
Copy Markdown
Member

@xeophon xeophon commented May 24, 2026

Issue

PR #1453 added scale_executors(concurrency=512) to EnvServer.run_server() so the router/server process could use a larger default executor for asyncio.to_thread work. The call happens before asyncio.run(server.run()), so there is no running event loop yet.

verifiers.utils.thread_utils.scale_executors() handles that case by creating/resizing the shared executor, but its documented contract says the caller must later call install_default_executor() from inside the real loop. EnvWorker.run() already does that. EnvServer.run() did not, so the server loop kept Python's default executor instead of the scaled one. In the local probe from the bug scan, the server-side loop was still at before_install=20, and only changed to after_install=512 after install_default_executor().

The practical bug is that the router/server half of #1453's event-loop-lag fix was only partially wired: scale_executors(512) created the intended executor, but the actual server event loop never used it. Any server-side asyncio.to_thread work would still be capped by the default executor rather than the configured 512-worker pool.

Fix

Call install_default_executor() at the start of EnvServer.run(), which is the first point where asyncio.run() has created the real event loop. This mirrors the worker lifecycle and keeps run_server() responsible for pre-loop scaling/uvloop setup.

This PR intentionally does not touch uv.lock and does not add a test.

Verification

  • uv run --frozen ruff format
  • uv run --frozen ruff check --fix
  • uv run --frozen pytest tests/test_env_server.py -q

Note

Fix executor installation in EnvServer.run by calling install_default_executor at startup

Adds a call to install_default_executor() at the start of EnvServer.run() in env_server.py, before the death pipe monitor and signal handlers are set up. This ensures the process-wide default executor is installed before any async or threaded work begins.

Macroscope summarized 556c341.

@xeophon xeophon added the codex label May 24, 2026
macroscopeapp[bot]
macroscopeapp Bot previously approved these changes May 24, 2026
@macroscopeapp
Copy link
Copy Markdown

macroscopeapp Bot commented May 24, 2026

Approvability

Verdict: Approved

This is a minimal bug fix that adds a documented utility call (install_default_executor()) to the appropriate async context. The function is designed for this exact use case and is safe to call multiple times.

You can customize Macroscope's approvability policy. Learn more.

@xeophon xeophon force-pushed the codex/fix-env-server-executor-install branch from 3b867da to 556c341 Compare May 24, 2026 07:36
@xeophon xeophon requested review from Copilot and mikasenghaas and removed request for Copilot May 24, 2026 07:37
@xeophon xeophon merged commit 31d811e into main May 25, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant