test(cuda.core): restore pyglet context after failed window setup - #2813
Merged
Conversation
Signed-off-by: Rui Luo <ruluo@nvidia.com>
This comment has been minimized.
This comment has been minimized.
rwgk
approved these changes
Sep 11, 2026
rwgk
left a comment
Contributor
There was a problem hiding this comment.
Thanks @rluo8 , LGTM, based on a codex review (findings below).
I'll go ahead and merge this as-is. I'll work on the P2 finding in a follow-on PR, with the goal to get both fixes into ctk-next asap.
(I think it's reasonable to ignore the P3 finding.)
Findings gpt-5.6-sol ultra
- P2 — Mirror the cleanup in bindings.
cuda_bindings/tests/test_graphics_apis.py:37retains the identical vulnerableWindow(...)construction. Its parametrized test atcuda_bindings/tests/test_graphics_apis.py:105can leave stale Pyglet state after the first skipped case. Apply the same fix there or centralize the lifecycle helper. - P3 — Add deterministic regression coverage. Nothing directly tests the snapshot/close/restore logic at
cuda_core/tests/test_graphics.py:71. Current Windows CI skips earlier while importingpyglet.glbecauseopengl32is unavailable, so it never exercises this branch. A mocked test should verify new windows close, the prior context is restored, and the original exception propagates.
Contributor
|
2 tasks
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.
Description
This is to fix bug 6737103.
Test test_graphics.py failed with exception pyglet.gl.lib.GLException: (0x1282): Invalid operation. The specified operation is not allowed in the current state.
But when running the test case one by one, it could be skipped. If running the whole file like pytest -v test_graphics.py on a MCDM Windows system, it would fail.
The cause is that when pyglet window construction fails after creating a new GL context, it can leave a partially constructed window and stale
current_context. The per-test cleanup incuda.corecollects the window, causing subsequent graphics tests to fail withGLExceptioninstead of skipping for the original unavailable GL capability.Record the existing pyglet windows and current context before window construction. If construction fails, close newly created windows and restore the previous context before re-raising the original exception.