8000 [3.14] gh-135871: Fix needless spinning in `_PyMutex_LockTimed` with … · python/cpython@80fc62f · GitHub
[go: up one dir, main page]

Skip to content
  • Commit 80fc62f

    Browse files
    [3.14] gh-135871: Fix needless spinning in _PyMutex_LockTimed with zero timeout (gh-135872) (gh-135946)
    The free threading build could spin unnecessarily on `_Py_yield()` if the initial compare and swap failed. (cherry picked from commit cbfaf41) Co-authored-by: Joseph Tibbertsma <josephtibbertsma@gmail.com>
    1 parent df1c124 commit 80fc62f

    File tree

    2 files changed

    +3
    -1
    lines changed

    2 files changed

    +3
    -1
    lines changed
    Lines changed: 2 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -0,0 +1,2 @@
    1+
    Non-blocking mutex lock attempts now return immediately when the lock is busy
    2+
    instead of briefly spinning in the :term:`free threading` build.

    Python/lock.c

    Lines changed: 1 addition & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -58,7 +58,7 @@ _PyMutex_LockTimed(PyMutex *m, PyTime_t timeout, _PyLockFlags flags)
    5858
    return PY_LOCK_ACQUIRED;
    5959
    }
    6060
    }
    61-
    else if (timeout == 0) {
    61+
    if (timeout == 0) {
    6262
    return PY_LOCK_FAILURE;
    6363
    }
    6464

    0 commit comments

    Comments
     (0)
    0