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

asyncio.gather(..., return_exceptions=True) swallows cancellation #76865

Closed
socketpair mannequin opened this issue Jan 27, 2018 · 8 comments
Closed

asyncio.gather(..., return_exceptions=True) swallows cancellation #76865

socketpair mannequin opened this issue Jan 27, 2018 · 8 comments
Labels
3.7 (EOL) end of life 3.8 only security fixes topic-asyncio type-bug An unexpected behavior, bug, or error

Comments

@socketpair
Copy link
Mannequin

socketpair mannequin commented Jan 27, 2018

BPO 32684
Nosy @bitdancer, @asvetlov, @socketpair, @1st1
PRs
  • bpo-32684: Fix gather to propagate cancel of itself with return_exceptions #7209
  • [3.7] bpo-32684: Fix gather to propagate cancel of itself with return_exceptions (GH-7209) #7222
  • [3.6] bpo-32684: Fix gather to propagate cancel of itself with return_exceptions #7224
  • bpo-32684: Fix nits in tests #7225
  • [3.7] bpo-32684: Fix nits in tests (GH-7225) #7231
  • 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 = None
    closed_at = <Date 2018-05-30.00:59:24.287>
    created_at = <Date 2018-01-27.05:38:11.141>
    labels = ['3.8', 'type-bug', '3.7', 'expert-asyncio']
    title = 'asyncio.gather(..., return_exceptions=True) swallows cancellation'
    updated_at = <Date 2018-05-30.00:59:24.286>
    user = 'https://github.com/socketpair'

    bugs.python.org fields:

    activity = <Date 2018-05-30.00:59:24.286>
    actor = 'yselivanov'
    assignee = 'none'
    closed = True
    closed_date = <Date 2018-05-30.00:59:24.287>
    closer = 'yselivanov'
    components = ['asyncio']
    creation = <Date 2018-01-27.05:38:11.141>
    creator = 'socketpair'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 32684
    keywords = ['patch']
    message_count = 8.0
    messages = ['310843', '310846', '318059', '318093', '318127', '318138', '318139', '318142']
    nosy_count = 4.0
    nosy_names = ['r.david.murray', 'asvetlov', 'socketpair', 'yselivanov']
    pr_nums = ['7209', '7222', '7224', '7225', '7231']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue32684'
    versions = ['Python 3.6', 'Python 3.7', 'Python 3.8']

    @socketpair
    Copy link
    Mannequin Author

    socketpair mannequin commented Jan 27, 2018

    Proof:

    ================

    import asyncio
    
    async def test():
        while True:
            print('sleeping 1')
            await asyncio.gather(asyncio.sleep(1), return_exceptions=True)
    
    async def amain():
        print('creating task')
        qwe = asyncio.Task(test())
        print('sleeping 2')
        await asyncio.sleep(2)
        print('cancelling task')
        qwe.cancel()
        print('waiting task for completion')
        try:
            await qwe
        except Exception as e:
            print('task complete: %r', e)
    
    loop = asyncio.get_event_loop()
    loop.run_until_complete(amain())

    ================

    This program will never complete.

    This case should be either fixed, or documented.

    @socketpair socketpair mannequin added 3.7 (EOL) end of life 3.8 only security fixes topic-asyncio type-bug An unexpected behavior, bug, or error labels Jan 27, 2018
    @bitdancer
    Copy link
    Member

    See also bpo-26923, but I think this problem is different.

    @1st1
    Copy link
    Member

    1st1 commented May 29, 2018

    Thanks for reporting this. Agree, this is a bug and makes it hard (if not impossible) to use gather. I've created a PR to address the issue.

    @1st1
    Copy link
    Member

    1st1 commented May 29, 2018

    New changeset 863b674 by Yury Selivanov in branch 'master':
    bpo-32684: Fix gather to propagate cancel of itself with return_exceptions (GH-7209)
    863b674

    @1st1
    Copy link
    Member

    1st1 commented May 29, 2018

    New changeset 0364342 by Yury Selivanov (Miss Islington (bot)) in branch '3.7':
    bpo-32684: Fix gather to propagate cancel of itself with return_exceptions (GH-7209) (bpo-7222)
    0364342

    @1st1
    Copy link
    Member

    1st1 commented May 29, 2018

    New changeset 3b263e6 by Yury Selivanov in branch '3.6':
    bpo-32684: Fix gather to propagate cancel of itself with return_exceptions (GH-7224)
    3b263e6

    @1st1
    Copy link
    Member

    1st1 commented May 29, 2018

    New changeset 6f75bae by Yury Selivanov in branch 'master':
    bpo-32684: Fix nits in tests (GH-7225)
    6f75bae

    @1st1
    Copy link
    Member

    1st1 commented May 30, 2018

    New changeset 3ddee64 by Yury Selivanov (Miss Islington (bot)) in branch '3.7':
    bpo-32684: Fix nits in tests (GH-7225) (bpo-7231)
    3ddee64

    @1st1 1st1 closed this as completed May 30, 2018
    @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 3.8 only security fixes topic-asyncio type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants