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

Task.current_task(None) returns unexpected result #73457

Closed
1st1 opened this issue Jan 13, 2017 · 6 comments
Closed

Task.current_task(None) returns unexpected result #73457

1st1 opened this issue Jan 13, 2017 · 6 comments
Assignees
Labels
3.7 (EOL) end of life topic-asyncio type-bug An unexpected behavior, bug, or error

Comments

@1st1
Copy link
Member

1st1 commented Jan 13, 2017

BPO 29271
Nosy @methane, @1st1, @lelit, @azazel75
PRs
  • bpo-29271: Fix Task.current_task and Task.all_tasks to accept None. #406
  • bpo-29271: Fix Task.current_task and Task.all_tasks to accept None. #413
  • [Do Not Merge] Sample of CPython life with blurb. #703
  • [Do Not Merge] Convert Misc/NEWS so that it is managed by towncrier #552
  • Files
  • task.patch
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = 'https://github.com/1st1'
    closed_at = <Date 2017-03-03.23:10:28.529>
    created_at = <Date 2017-01-13.22:11:24.834>
    labels = ['type-bug', '3.7', 'expert-asyncio']
    title = 'Task.current_task(None) returns unexpected result'
    updated_at = <Date 2017-03-31.16:36:33.267>
    user = 'https://github.com/1st1'

    bugs.python.org fields:

    activity = <Date 2017-03-31.16:36:33.267>
    actor = 'dstufft'
    assignee = 'yselivanov'
    closed = True
    closed_date = <Date 2017-03-03.23:10:28.529>
    closer = 'yselivanov'
    components = ['asyncio']
    creation = <Date 2017-01-13.22:11:24.834>
    creator = 'yselivanov'
    dependencies = []
    files = ['46284']
    hgrepos = []
    issue_num = 29271
    keywords = ['patch']
    message_count = 6.0
    messages = ['285445', '285447', '285448', '285456', '288855', '290338']
    nosy_count = 4.0
    nosy_names = ['methane', 'yselivanov', 'lelit', 'azazel']
    pr_nums = ['406', '413', '703', '552']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue29271'
    versions = ['Python 3.6', 'Python 3.7']

    @1st1
    Copy link
    Member Author

    1st1 commented Jan 13, 2017

    Quoting Alberto Berdi from python-tulip mailing list:

    working with the Python 3.6 asyncio implemented in C, i've got what is
    for me a strange behavior of the asyncio.Task.current task
    function. Executing the following test:

     import asyncio
    
     async def coro():
         print(asyncio.Task.current_task())
         print(asyncio.Task.current_task(None))
         print(asyncio.Task.current_task(loop=asyncio.get_event_loop()))
    
     loop = asyncio.get_event_loop()
     loop.run_until_complete(coro())

    in Py3.5, I obtain the result:

    <Task pending coro=<coro() running at test_task.py:4> cb=[_run_until_complete_cb() at /usr/lib/python3.5/asyncio/base_events.py:176]>
    <Task pending coro=<coro() running at test_task.py:5> cb=[_run_until_complete_cb() at /usr/lib/python3.5/asyncio/base_events.py:176]>
    <Task pending coro=<coro() running at test_task.py:6> cb=[_run_until_complete_cb() at /usr/lib/python3.5/asyncio/base_events.py:176]>

    In Py3.6, i get:

    <Task pending coro=<coro() running at test_task.py:4> cb=[_run_until_complete_cb() at /usr/lib/python3.6/asyncio/base_events.py:176]>
    None
    <Task pending coro=<coro() running at test_task.py:6> cb=[_run_until_complete_cb() at /usr/lib/python3.6/asyncio/base_events.py:176]>

    What's going on here? It's still right to expect the same result from the three calls or something has changed?
    The documentation for the Task.current_task() function seems unchanged between the two version.

    My python3.6 has version:

    $ python3.6 -VV
    Python 3.6.0 (default, Dec 29 2016, 04:29:02) 
    [GCC 6.2.1 20161215]

    @1st1 1st1 added the 3.7 (EOL) end of life label Jan 13, 2017
    @1st1 1st1 self-assigned this Jan 13, 2017
    @1st1 1st1 added topic-asyncio type-bug An unexpected behavior, bug, or error labels Jan 13, 2017
    @lelit
    Copy link
    Mannequin

    lelit mannequin commented Jan 13, 2017

    FWIW, the problem afflicts other functions, for example the following script exhibits a similar difference:

    import asyncio
    
    async def coro():
        print(asyncio.Task.all_tasks())
        print(asyncio.Task.all_tasks(None))
    
    loop = asyncio.get_event_loop()
    loop.run_until_complete(coro())

    @lelit
    Copy link
    Mannequin

    lelit mannequin commented Jan 13, 2017

    Yay, Yury is too fast!! :-)

    @methane
    Copy link
    Member

    methane commented Jan 14, 2017

    LGTM

    @1st1
    Copy link
    Member Author

    1st1 commented Mar 3, 2017

    New changeset 13802a3 by Yury Selivanov in branch '3.6':
    bpo-29271: Fix Task.current_task and Task.all_tasks to accept None. (#406)
    13802a3

    @1st1 1st1 closed this as completed Mar 3, 2017
    @1st1
    Copy link
    Member Author

    1st1 commented Mar 24, 2017

    New changeset 8d26aa9 by Yury Selivanov in branch 'master':
    bpo-29271: Fix Task.current_task and Task.all_tasks to accept None. (#406)
    8d26aa9

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.7 (EOL) end of life topic-asyncio type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants