Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improper call to asyncio.Timeout.expired #101498

Closed
rsokl opened this issue Feb 1, 2023 · 0 comments
Closed

Improper call to asyncio.Timeout.expired #101498

rsokl opened this issue Feb 1, 2023 · 0 comments
Labels
docs Documentation in the Doc dir topic-asyncio

Comments

@rsokl
Copy link

rsokl commented Feb 1, 2023

Documentation

In this example for using asyncio.Timeout, expired is accessed as an attribute, but it should be called as a method.

I.e. the example should read as:

async def main():
    try:
        # We do not know the timeout when starting, so we pass ``None``.
        async with asyncio.timeout(None) as cm:
            # We know the timeout now, so we reschedule it.
            new_deadline = get_running_loop().time() + 10
            cm.reschedule(new_deadline)

            await long_running_task()
    except TimeoutError:
        pass

    if cm.expired():  # <---- I CHANGED THIS TO BE A METHOD CALL
        print("Looks like we haven't finished on time.")

Linked PRs

@rsokl rsokl added the docs Documentation in the Doc dir label Feb 1, 2023
gvanrossum pushed a commit that referenced this issue Feb 1, 2023
Doc/library/asyncio-task.rst#timeout
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Feb 1, 2023
Doc/library/asyncio-task.rstGH-timeout
(cherry picked from commit 95fb0e0)

Co-authored-by: Raj <51259329+workingpayload@users.noreply.github.com>
miss-islington added a commit that referenced this issue Feb 1, 2023
Doc/library/asyncio-task.rstGH-timeout
(cherry picked from commit 95fb0e0)

Co-authored-by: Raj <51259329+workingpayload@users.noreply.github.com>
carljm added a commit to carljm/cpython that referenced this issue Feb 1, 2023
* main:
  pythongh-98831: rewrite PUSH_EXC_INFO and conditional jumps in the instruction definition DSL (python#101481)
  pythongh-98831: Modernize the LOAD_ATTR family (python#101488)
  pythongh-101498 : Fix asyncio.Timeout example in docs (python#101499)
  pythongh-101454: fix documentation for END_ASYNC_FOR (python#101455)
  pythongh-101277: Isolate itertools, add group and _grouper types to module state (python#101302)
  pythongh-101317: Add `ssl_shutdown_timeout` parameter for `asyncio.StreamWriter.start_tls` (python#101335)
  datetime.rst: fix combine() signature (python#101490)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir topic-asyncio
Projects
Status: Done
Development

No branches or pull requests

3 participants