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-74953: PyThread_acquire_lock_timed() recomputes timeout#93946

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

Closed
vstinner wants to merge1 commit intopython:mainfromvstinner:lock_timeout
Closed

gh-74953: PyThread_acquire_lock_timed() recomputes timeout#93946

vstinner wants to merge1 commit intopython:mainfromvstinner:lock_timeout

Conversation

vstinner
Copy link
Member

The mutex with conditional variable implementation of lock now
recomputes the timeout if acquire(timeout=timeout) is interrupted by
a signal.

@vstinnervstinner marked this pull request as ready for reviewJune 20, 2022 14:20
@vstinner
Copy link
MemberAuthor

macOS job failed with:

0:05:19 load avg: 9.67 [ 99/436/1] test_concurrent_futures failed (env changed) (3 min 15 sec)(...)Warning -- sys.stderr was modified by test_concurrent_futuresWarning --   Before: <_io.StringIO object at 0x10d1a5590>Warning --   After:  <_io.StringIO object at 0x10d822cb0>

I don't know if it's related to the PR.

@vstinner
Copy link
MemberAuthor

PR rebased on main to get fixes for unrelated compiler warnings.

The mutex with conditional variable implementation of lock nowrecomputes the timeout if acquire(timeout=timeout) is interrupted bya signal.
@vstinner
Copy link
MemberAuthor

I'm no longer convinced that this change is needed:

  • On Linux, USE_SEMAPHORES macro is defined: use sem_clockwait(), or sem_timedwait()
  • If I manually undefine the USE_SEMAPHORES macro to use mutex+condvar implementation, I failed to interrupt pthread_cond_timedwait() with a signal. If it's called with a timeout of 5 seconds and an interrupt is received in 1 second, pthread_cond_timedwait() function does not return EINTR but blocks for 5 seconds.

Locks used in Python call PyThread_acquire_lock_timed() with intr_flag=1: if a function returns EINTR, it returns immediately, the caller checks for signals, and then calls again the function to try again to acquire to lock with a re-computed timeout.

I close my PR. But I wrote PR#94056 to clean-up the code.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@vstinner@bedevere-bot

[8]ページ先頭

©2009-2025 Movatter.jp