GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-74953: PyThread_acquire_lock_timed() recomputes timeout by vstinner · Pull Request #93946 · python/cpython

Conversation

@vstinner

@vstinner vstinner commented Jun 17, 2022

Copy link
Copy Markdown
Member

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bedevere-bot bedevere-bot added the awaiting core review label Jun 17, 2022
@vstinner
vstinner marked this pull request as ready for review June 20, 2022 14:20
@vstinner

vstinner commented Jun 20, 2022

Copy link
Copy Markdown
Member Author

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_futures
Warning --   Before: <_io.StringIO object at 0x10d1a5590>
Warning --   After:  <_io.StringIO object at 0x10d822cb0>

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vstinner

vstinner commented Jun 20, 2022

Copy link
Copy Markdown
Member Author

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vstinner vstinner added the skip news label Jun 20, 2022
@vstinner
gh-74953: PyThread_acquire_lock_timed() recomputes timeout
4a8ea95
The mutex with conditional variable implementation of lock now
recomputes the timeout if acquire(timeout=timeout) is interrupted by
a signal.
@vstinner vstinner removed the skip news label Jun 20, 2022
@vstinner

vstinner commented Jun 21, 2022

Copy link
Copy Markdown
Member Author

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vstinner vstinner closed this Jun 21, 2022
@vstinner
vstinner deleted the lock_timeout branch June 21, 2022 12:33
@vstinner vstinner mentioned this pull request Jun 21, 2022
PyThread_acquire_lock_timed() should recompute the timeout when interrupted by a signal #74953
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

awaiting core review

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@vstinner @bedevere-bot
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.