Registry Mirror
Skip to content

[asyncio] orphan future close loop and cause "RuntimeError: Event loop stopped before Future completed." #74608

Closed

Description

@jimmylai
mannequin
BPO 30423
Nosy @asvetlov, @ambv, @1st1, @jimmylai
PRs
  • [asyncio] bpo-30423 bug: orphan future close loop and cause "RuntimeError: Event loop stopped before Future completed." #1688
  • [3.6] bpo-30423: call remove_done_callback in finally section (GH-1688) #1755
  • [3.5] bpo-30423: call remove_done_callback in finally section (GH-1688) #1758
  • [asyncio] bpo-30423: add regression test for orphan future causes "RuntimeError: Event loop stopped before Future completed." #3295
  • 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 2017-05-23.07:37:31.504>
    created_at = <Date 2017-05-21.13:44:28.150>
    labels = ['3.7', 'expert-asyncio']
    title = '[asyncio] orphan future close loop and cause "RuntimeError: Event loop stopped before Future completed."'
    updated_at = <Date 2017-11-01.13:54:48.076>
    user = 'https://github.com/jimmylai'

    bugs.python.org fields:

    activity = <Date 2017-11-01.13:54:48.076>
    actor = 'asvetlov'
    assignee = 'none'
    closed = True
    closed_date = <Date 2017-05-23.07:37:31.504>
    closer = 'lukasz.langa'
    components = ['asyncio']
    creation = <Date 2017-05-21.13:44:28.150>
    creator = 'jimmylai'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 30423
    keywords = []
    message_count = 2.0
    messages = ['294102', '305382']
    nosy_count = 4.0
    nosy_names = ['asvetlov', 'lukasz.langa', 'yselivanov', 'jimmylai']
    pr_nums = ['1688', '1755', '1758', '3295']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue30423'
    versions = ['Python 3.5', 'Python 3.6', 'Python 3.7']

    Activity

    1. jimmylai commented on May 21, 2017

      jimmylaimannequin
      MannequinAuthor

      Problem:
      "RuntimeError: Event loop stopped before Future completed." throws when calling run_until_complete().

      We investigate and find out some orphan futures stay in the event loop before we run another run_until_complete(another_async_func()).
      The orphan future has pending state and is attached with _run_until_complete_cb from previous run_until_complete.
      It happens because the orphan future thrown Exception and then raise, thus remove_done_callback(_run_until_complete_cb) didn't called.
      Move it to finally section can fix it.
      With this patch, we stop seeing the Runtime Error.

    2. asvetlov commented on Nov 1, 2017

      @asvetlov
      Contributor

      New changeset d1e3403 by Andrew Svetlov (jimmylai) in branch 'master':
      [asyncio] bpo-30423: add regression test for orphan future causes "RuntimeError: Event loop stopped before Future completed." (bpo-3295)
      d1e3403

    3. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions