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 — [3.10] bpo-41710: Fix PY_TIMEOUT_MAX value on Windows by vstinner · Pull Request #28672 · python/cpython

Conversation

@vstinner

@vstinner vstinner commented Oct 1, 2021 •
edited by bedevere-bot
Loading

Uh oh!

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

Copy link
Copy Markdown
Member

Fix _thread.TIMEOUT_MAX value on Windows: the maximum timeout is
0x7FFFFFFF milliseconds (around 24.9 days), not 0xFFFFFFFF
milliseconds (around 49.7 days).

Set PY_TIMEOUT_MAX to 0x7FFFFFFF milliseconds, rather than 0xFFFFFFFF
milliseconds.

https://bugs.python.org/issue41710

Sorry, something went wrong.

Uh oh!

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

All reactions
@vstinner
bpo-41710: Fix PY_TIMEOUT_MAX value on Windows
e04ec66
Fix _thread.TIMEOUT_MAX value on Windows: the maximum timeout is
0x7FFFFFFF milliseconds (around 24.9 days), not 0xFFFFFFFF
milliseconds (around 49.7 days).

Set PY_TIMEOUT_MAX to 0x7FFFFFFF milliseconds, rather than 0xFFFFFFFF
milliseconds.
@bedevere-bot bedevere-bot added the awaiting core review label Oct 1, 2021
@the-knights-who-say-ni the-knights-who-say-ni added the CLA signed label Oct 1, 2021
@vstinner

vstinner commented Oct 1, 2021

Copy link
Copy Markdown
Member Author

Oh, I read WaitForSingleObject documentation of 2006 for Windows CE 3.0:
https://docs.microsoft.com/en-us/previous-versions/ms915517(v=msdn.10)

The time-out value needs to be a positive number between 0 and 0x7FFFFFFF. The maximum time-out value not equal to infinity is 0x7FFFFFFF. The infinite time-out value is 0xFFFFFFFF. Any time-out value between 0x7FFFFFFF and 0xFFFFFFFF—that is, values from 0xF0000000 through 0xFFFFFFFE—is equivalent to 0x7FFFFFFF. If you need a bigger time-out value than the maximum of 0x7FFFFFFF, use the value for infinity (0xFFFFFFFF).

Maybe this is different on Windows 10 and my change in the main branch is not correct.

All reactions

Sorry, something went wrong.

Uh oh!

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

@vstinner

vstinner commented Oct 1, 2021

Copy link
Copy Markdown
Member Author

In ReactOS, WaitForSingleObject() calls WaitForSingleObjectEx() which converts "DWORD dwMilliseconds" to "LARGE_INTEGER Time" with BaseFormatTimeOut()

 PLARGE_INTEGER
 WINAPI
 BaseFormatTimeOut(OUT PLARGE_INTEGER Timeout,
                   IN DWORD dwMilliseconds)
 {
     /* Check if this is an infinite wait, which means no timeout argument */
     if (dwMilliseconds == INFINITE) return NULL;
 
     /* Otherwise, convert the time to NT Format */
     Timeout->QuadPart = dwMilliseconds * -10000LL;
     return Timeout;
 }

Then WaitForSingleObjectEx() calls NtWaitForSingleObject() with the "LARGE_INTEGER Time".

So I don't see any special case for values in the [0x80000000; 0xFFFFFFFE] range. Only INFINITE is special. In ReactOS, INFINITE is defined as:

#define INFINITE MAXULONG

I understand that INFINITE is equal to 0xFFFFFFFF.

All reactions

Sorry, something went wrong.

Uh oh!

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

@vstinner

vstinner commented Oct 1, 2021

Copy link
Copy Markdown
Member Author

The code in the main branch, I wrote PR #28673 to fix it instead.

All reactions

Sorry, something went wrong.

Uh oh!

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

@vstinner vstinner closed this Oct 1, 2021
@vstinner
vstinner deleted the timeout_max branch October 1, 2021 09:26
@vstinner vstinner mentioned this pull request Oct 1, 2021
bpo-41710: Fix PY_TIMEOUT_MAX on Windows #28673
Merged
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.

3 participants

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