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 — bpo-21302: Add nanosleep() implementation for time.sleep() in Unix by Livius90 · Pull Request #28526 · python/cpython

Conversation

@Livius90

@Livius90 Livius90 commented Sep 22, 2021 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor
  • Use nanosleep() for time.sleep() in Unix operation systems in case if clock_nanosleep() is not available but nanosleep() is available.

Some previous pull request history can be found here: #28111, #28341, #28483

  • nanosleep() is supported in the following operating systems: Linux (since 2001), FreeBSD (since 1997), OpenBSD (since 1997), NetBSD (since 1997), IBM AIX (since v7.1 2010), macOS (since OS X v10.9 2013)
  • clock_nanosleep() is supported in the following operating systems: Linux (since 2001), FreeBSD (since 2008), NetBSD (since 2014), IBM AIX (since v7.1 2010)

https://bugs.python.org/issue21302

Sorry, something went wrong.

Uh oh!

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

All reactions
@Livius90
replace select() to nanosleep()
0f39807
Replace outdated select() to use nanosleep() for sleep implementation in Unix
@Livius90
Livius90 requested review from abalkin and pganssle as code owners September 22, 2021 23:38
@the-knights-who-say-ni the-knights-who-say-ni added the CLA signed label Sep 22, 2021
@bedevere-bot bedevere-bot added the awaiting review label Sep 22, 2021
@blurb-it
📜🤖 Added by blurb_it.
955a47f
vstinner
vstinner reviewed Sep 23, 2021
View reviewed changes

@vstinner vstinner left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer to restrict this PR to using nanosleep() in time.sleep(), and nothing else. IMO it's already complex enough :-)

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread Modules/_tkinter.c Resolved

Uh oh!

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

Comment thread Modules/_multiprocessing/semaphore.c Resolved

Uh oh!

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

Comment thread Modules/timemodule.c Resolved

Uh oh!

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

Livius90 added 3 commits September 23, 2021 22:02
@Livius90
revert some changes
3e2bb51
@Livius90
Add HAVE_NANOSLEEP to configure.ac
75fcb70
@Livius90
Update news rst
03659cb
@Livius90
Livius90 requested a review from vstinner September 23, 2021 21:39
@vstinner vstinner mentioned this pull request Sep 24, 2021
bpo-21302: Add nanosleep() implementation for time.sleep() in Unix #28545
Merged
vstinner
vstinner reviewed Sep 24, 2021
View reviewed changes
Comment thread Modules/timemodule.c

do {
#ifndef HAVE_CLOCK_NANOSLEEP
#if defined(HAVE_NANOSLEEP) && !defined(HAVE_CLOCK_NANOSLEEP)

@vstinner vstinner Sep 24, 2021

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change LGTM, but I propose to write the #ifdef dance differently and rename secs to timeout to make the code more readable. I created PR #28545 based on your PR. Is it better? For the main code in Py_BEGIN_ALLOW_THREADS/Py_END_ALLOW_THREADS, I merged the 3 code paths to put if #ifdef in the Py_BEGIN_ALLOW_THREADS block. What do you think?

Sorry, something went wrong.

Uh oh!

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

All reactions
@vstinner

vstinner commented Sep 25, 2021

Copy link
Copy Markdown
Member

I merged PR #28545.

All reactions

Sorry, something went wrong.

Uh oh!

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

@vstinner vstinner closed this Sep 25, 2021
@Livius90
Livius90 deleted the unix_nanosleep branch September 27, 2021 22:57
@shankarunni shankarunni mannequin mentioned this pull request Nov 12, 2022
time.sleep (floatsleep()) should use clock_nanosleep() on Linux #65501
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@vstinner vstinner vstinner left review comments
@abalkin abalkin Awaiting requested review from abalkin
@pganssle pganssle Awaiting requested review from pganssle pganssle is a code owner

Uh oh!

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

Assignees

No one assigned

Labels

awaiting 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.

4 participants

@Livius90 @vstinner @the-knights-who-say-ni @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 01402520 — 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.