| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| Expand Up | @@ -639,10 +639,34 @@ def __sleep0(): | |||||
| """ | ||||||
| yield | ||||||
|
|
||||||
| def __check_delay(delay): | ||||||
| """Check if the value of 'delay' is valid.""" | ||||||
|
|
||||||
| import sys | ||||||
| import math | ||||||
|
|
||||||
| SEC_TO_NS = 1000 * 1000 * 1000 | ||||||
|
|
||||||
| if not (isinstance(delay, int) or isinstance(delay, float)): | ||||||
|
Comment thread
Copy link
Copy Markdown
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality
Suggested change
Sorry, something went wrong.
All reactions
Copy link
Copy Markdown
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityWow! This is much clearer now.
Sorry, something went wrong.
All reactions
|
||||||
| raise TypeError(f"'{type(delay)} object cannot be interpreted as an integer'") | ||||||
|
Comment thread
Copy link
Copy Markdown
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality
Suggested change
There's no need for single quotes.
Sorry, something went wrong.
All reactions
Copy link
Copy Markdown
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityOk
Sorry, something went wrong.
All reactions
|
||||||
|
|
||||||
| # According to Modules/timemodule.c | ||||||
| if (delay > sys.maxsize / SEC_TO_NS): | ||||||
| raise OverflowError("timestamp too large to convert to C _PyTime_t") | ||||||
|
|
||||||
| if (delay < 0): | ||||||
| raise ValueError("sleep length must be non-negative") | ||||||
|
|
||||||
| if (math.isnan(delay)): | ||||||
| raise ValueError("Invalid value NaN (not a number)") | ||||||
|
|
||||||
|
|
||||||
| async def sleep(delay, result=None): | ||||||
| """Coroutine that completes after a given time (in seconds).""" | ||||||
| if delay <= 0: | ||||||
|
|
||||||
| __check_delay(delay) | ||||||
|
|
||||||
| if delay == 0: | ||||||
| await __sleep0() | ||||||
| return result | ||||||
|
|
||||||
| Expand Down | ||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Fix asyncio.sleep(float('nan')) does not raise ValueError |
| Back | FazBrowse Home | New Git URL |
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.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityNitpick: Does it really need double underscore? If you want to mark something as "private API" use one leading underscore
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
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.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityGet it!
Thank you
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.