Commit ba1a57e
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 c30a373 commit ba1a57e
2 files changed
Lines changed: 42 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
| |||
140 | 141 | | |
141 | 142 | | |
142 | 143 | | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
143 | 147 | | |
144 | 148 | | |
145 | 149 | | |
| |||
152 | 156 | | |
153 | 157 | | |
154 | 158 | | |
155 | | - | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
156 | 165 | | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | | - | |
| 166 | + | |
| 167 | + | |
164 | 168 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
155 | 155 | | |
156 | 156 | | |
157 | 157 | | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
158 | 188 | | |
159 | 189 | | |
160 | 190 | | |
| |||
0 commit comments