Commit 45811fd
committed
gh-135871: Fix needless spinning in _PyMutex_LockTimed (timeout==0)
* Move the timeout == 0 guard outside the else so a non-blocking call
returns immediately after a failed CAS instead of entering the spin loop.
* Reload v on every spin iteration, allowing timed/blocking callers to
notice an unlock promptly.
No-GIL builds now honor the semantics of non-blocking attempts and avoid
wasted CPU; GIL builds are unaffected (MAX_SPIN_COUNT == 0).1 parent 34393cb commit 45811fd
File tree
2 files changed
+3
-1
lines changed- Misc/NEWS.d/next/Core and Builtins
- Python
2 files changed
+3
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
61 | | - | |
| 61 | + | |
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
| |||
89 | 89 | | |
90 | 90 | | |
91 | 91 | | |
| 92 | + | |
92 | 93 | | |
93 | 94 | | |
94 | 95 | | |
| |||
0 commit comments