Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-134745: Change PyThread_allocate_lock() implementation to PyMutex#134747

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
vstinner merged 7 commits intopython:mainfromvstinner:pymutex
May 30, 2025
Merged
Show file tree
Hide file tree
Changes from1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
PrevPrevious commit
NextNext commit
Add _PY_FAIL_IF_INTERRUPTED flag
Don't call signal handlers if interrupted, only return PY_LOCK_INTR.
  • Loading branch information
@vstinner
vstinner committedMay 28, 2025
commitf7347457f1e8e4209417bd98459966ff372879d0
3 changes: 3 additions & 0 deletionsInclude/internal/pycore_lock.h
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -48,6 +48,9 @@ typedef enum _PyLockFlags {

// Handle signals if interrupted while waiting on the lock.
_PY_LOCK_HANDLE_SIGNALS = 2,

// Fail if interrupted by a signal while waiting on the lock.
_PY_FAIL_IF_INTERRUPTED = 4,
} _PyLockFlags;

// Lock a mutex with an optional timeout and additional options. See
Expand Down
3 changes: 3 additions & 0 deletionsPython/lock.c
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -119,6 +119,9 @@ _PyMutex_LockTimed(PyMutex *m, PyTime_t timeout, _PyLockFlags flags)
return PY_LOCK_INTR;
}
}
else if (ret == Py_PARK_INTR && (flags & _PY_FAIL_IF_INTERRUPTED)) {
return PY_LOCK_INTR;
}
else if (ret == Py_PARK_TIMEOUT) {
assert(timeout >= 0);
return PY_LOCK_FAILURE;
Expand Down
2 changes: 1 addition & 1 deletionPython/thread.c
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -119,7 +119,7 @@ PyThread_acquire_lock_timed(PyThread_type_lock lock, PY_TIMEOUT_T microseconds,

_PyLockFlags flags = _Py_LOCK_DONT_DETACH;
if (intr_flag) {
flags |=_PY_LOCK_HANDLE_SIGNALS;
flags |=_PY_FAIL_IF_INTERRUPTED;
}

return _PyMutex_LockTimed((PyMutex *)lock, timeout, flags);
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp