{{ message }}
Commit fe4b2fe
pathfinder: simplify NVML init/shutdown handling and document ref-count contract
Collapse the duplicated ``nvmlShutdown()`` calls in
``_query_driver_release_version_text`` into a single ``try/finally`` so
the cleanup always runs in one place. The asymmetric error-precedence
rule is preserved via ``sys.exc_info()[1]``: when both the NVML body and
shutdown fail, the body's error wins (Python keeps the shutdown error
on ``__context__`` for debugging); when only shutdown fails, the
shutdown error surfaces.
Add comments above the matched ``nvmlInit_v2()`` / ``nvmlShutdown()``
pair noting that NVML's init/shutdown is reference-counted, so this
balanced pair is safe even when the caller has already initialized NVML
elsewhere in the process. Pre-empts a question raised in review on
PR #2000.
Add two focused tests filling out the cleanup matrix:
- ``test_query_driver_release_version_text_raises_when_only_shutdown_fails``
asserts a non-zero shutdown status surfaces when the body succeeded.
- ``test_query_driver_release_version_text_body_error_wins_when_both_fail``
locks in the body-error-wins precedence when both calls fail.
Co-authored-by: Cursor <cursoragent@cursor.com>1 parent 356049d commit fe4b2fe
2 files changed
Lines changed: 42 additions & 8 deletions

0 commit comments