Repository navigation
Codex device-poll tests: fake asyncio.sleep only on the test's own thread - #13457
Merged
Merged
Conversation
…read codex_auth.asyncio is the asyncio module, so patching its sleep replaced asyncio.sleep for every event loop in the worker. A loop left running by an earlier test then spun on the instant fake and flooded the recorded sleeps, and the assert's repr of that list ran past the 330 s pytest-timeout (seen on #13445). Route other threads to the real sleep.
Member
Author
|
@codex review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Didn't find any major issues. Swish! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
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.
Problem
studio/backend/tests/test_openai_codex_subscription.py::test_device_poll_shape_structured_pending_slow_down_and_exchangetimed out in(Python 3.13, l-r)on #13445, which only touched unrelated tests:At the timeout, the test thread was inside pytest's assertion repr (
pprint.pformat) for that assert.Cause: both device-poll tests (from #8511) do
monkeypatch.setattr(codex_auth.asyncio, "sleep", fake_sleep).codex_auth.asynciois theasynciomodule itself, so this replacesasyncio.sleepfor every event loop in the process, not just the poll under test. An event loop that an earlier test left running in the same xdist worker then gets the instant fake on every tick. It spins and appends tosleeps,sleeps == [1, 1, 6]fails, and rendering that list runs past the timeout. The product code is fine.Reproduced on main: with one background event loop calling
asyncio.sleep(0.01)during the test, it fails withassert [1, 1, 6, 0.01, 0.01, ...] == [1, 1, 6].Fix
A
_patch_poll_sleep(monkeypatch, record = None)helper, used by both tests. The fake records and returns at once only on the thread that installed it; any other thread'sasyncio.sleepgoes to the real one.Verification
sleepsfloodedSabotage, product changed, this PR's test: changing the
slow_downbackoff inopenai_codex_auth.pyfrom+ 5to+ 4fails with[1, 1, 5] == [1, 1, 6].Formatted with the repo's ruff-format-with-kwargs hook.