Skip to content

test_asyncio: test_cancel_gather_2() dangling thread #81318

Closed

Description

@vstinner
BPO 37137
Nosy @vstinner, @asvetlov, @pablogsal
PRs
  • bpo-37137: Fix test_asyncio: use TestCase.set_event_loop() #13779
  • bpo-37137, asyncio: add BaseEventLoop.wait_executor_on_close #13786
  • bpo-37137: Close pid waiters on watcher.close() #13792
  • 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 2019-06-04.12:43:35.166>
    created_at = <Date 2019-06-03.01:18:08.370>
    labels = ['3.8', 'tests']
    title = 'test_asyncio: test_cancel_gather_2() dangling thread'
    updated_at = <Date 2019-06-04.12:43:35.165>
    user = 'https://github.com/vstinner'

    bugs.python.org fields:

    activity = <Date 2019-06-04.12:43:35.165>
    actor = 'vstinner'
    assignee = 'none'
    closed = True
    closed_date = <Date 2019-06-04.12:43:35.166>
    closer = 'vstinner'
    components = ['Tests']
    creation = <Date 2019-06-03.01:18:08.370>
    creator = 'vstinner'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 37137
    keywords = ['patch']
    message_count = 17.0
    messages = ['344353', '344358', '344359', '344426', '344427', '344433', '344471', '344479', '344481', '344488', '344489', '344490', '344491', '344492', '344497', '344516', '344557']
    nosy_count = 3.0
    nosy_names = ['vstinner', 'asvetlov', 'pablogsal']
    pr_nums = ['13779', '13786', '13792']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue37137'
    versions = ['Python 3.8']

    Activity

    1. vstinner commented on Jun 3, 2019

      @vstinner
      MemberAuthor

      s390x RHEL 3.x buildbot:
      https://buildbot.python.org/all/#/builders/21/builds/3150

      test_cancel_gather_1 (test.test_asyncio.test_tasks.CTaskSubclass_PyFuture_Tests)
      Ensure that a gathering future refuses to be cancelled once all ... ok
      test_cancel_gather_2 (test.test_asyncio.test_tasks.CTaskSubclass_PyFuture_Tests) ...
      Warning -- threading_cleanup() failed to cleanup -1 threads (count: 0, dangling: 1)
      Dangling thread: <_MainThread(MainThread, started 4396153272064)>
      ok

      test_cancel_inner_future (test.test_asyncio.test_tasks.CTaskSubclass_PyFuture_Tests) ... ok
      test_cancel_task_catching (test.test_asyncio.test_tasks.CTaskSubclass_PyFuture_Tests) ... ok

      --

      AMD64 FreeBSD 10-STABLE Non-Debug 3.x:
      https://buildbot.python.org/all/#/builders/167/builds/1181

      test_cancel_gather_2 (test.test_asyncio.test_tasks.CTaskSubclass_PyFuture_Tests) ... Warning -- threading_cleanup() failed to cleanup -1 threads (count: 0, dangling: 1)

    2. added
      3.8 (EOL)
      tests
      on Jun 3, 2019
    3. vstinner commented on Jun 3, 2019

      @vstinner
      MemberAuthor

      Another similar error on "ARMv7 Debian buster 3.x" buildbot:
      https://buildbot.python.org/all/#/builders/176/builds/664

      test_proc_exited (test.test_asyncio.test_subprocess.SubprocessTransportTests) ... Warning -- threading_cleanup() failed to cleanup -1 threads (count: 0, dangling: 1)

    4. vstinner commented on Jun 3, 2019

      @vstinner
      MemberAuthor

      AMD64 Ubuntu Shared 3.x:
      https://buildbot.python.org/all/#/builders/141/builds/1912

      test_proc_exited (test.test_asyncio.test_subprocess.SubprocessTransportTests) ... Warning -- threading_cleanup() failed to cleanup -1 threads (count: 0, dangling: 1)
      test_close (test.test_asyncio.test_unix_events.SafeChildWatcherTests) ... /srv/buildbot/buildarea/3.x.bolen-ubuntu/build/Lib/asyncio/base_events.py:646: ResourceWarning: unclosed event loop <_UnixSelectorEventLoop running=False closed=False debug=False>
      _warn(f"unclosed event loop {self!r}", ResourceWarning, source=self)
      ResourceWarning: Enable tracemalloc to get the object allocation traceback

    5. vstinner commented on Jun 3, 2019

      @vstinner
      MemberAuthor

      https://buildbot.python.org/all/#/builders/167/builds/1188

      Variant:

      test_cancel_both_task_and_inner_future (test.test_asyncio.test_tasks.CTaskSubclass_PyFuture_Tests) ... ok
      test_cancel_current_task (test.test_asyncio.test_tasks.CTaskSubclass_PyFuture_Tests) ... ok
      test_cancel_gather_1 (test.test_asyncio.test_tasks.CTaskSubclass_PyFuture_Tests)
      Ensure that a gathering future refuses to be cancelled once all ... Warning -- threading_cleanup() failed to cleanup -1 threads (count: 0, dangling: 1)
      Dangling thread: <_MainThread(MainThread, started 34389124096)>
      ok
      test_cancel_gather_2 (test.test_asyncio.test_tasks.CTaskSubclass_PyFuture_Tests) ... ok
      test_cancel_inner_future (test.test_asyncio.test_tasks.CTaskSubclass_PyFuture_Tests) ... ok
      test_cancel_task_catching (test.test_asyncio.test_tasks.CTaskSubclass_PyFuture_Tests) ... ok

    6. vstinner commented on Jun 3, 2019

      @vstinner
      MemberAuthor

      See also bpo-34037: "asyncio: BaseEventLoop.close() shutdowns the executor without waiting causing leak of dangling threads".

    7. vstinner commented on Jun 3, 2019

      @vstinner
      MemberAuthor

      New changeset 49a7e34 by Victor Stinner in branch 'master':
      bpo-37137: Fix test_asyncio: use TestCase.set_event_loop() (GH-13779)
      49a7e34

    8. vstinner commented on Jun 3, 2019

      @vstinner
      MemberAuthor

      My change didn't fix the issue:

      https://buildbot.python.org/all/#/builders/176/builds/680

      test_proc_exited (test.test_asyncio.test_subprocess.SubprocessTransportTests) ... Warning -- threading_cleanup() failed to cleanup -1 threads (count: 0, dangling: 1)

    9. vstinner commented on Jun 3, 2019

      @vstinner
      MemberAuthor

      I push a fix in asyncio, instead of trying to fix individual asyncio tests:

      New changeset 0f0a30f by Victor Stinner in branch 'master':
      bpo-34037, asyncio: add BaseEventLoop.wait_executor_on_close (GH-13786)
      0f0a30f

      See https://bugs.python.org/issue34037#msg344476

    10. vstinner commented on Jun 3, 2019

      @vstinner
      MemberAuthor

      My second attempt isn't fully successful :-( test_asyncio still fails with ENV_CHANGED :-(

      https://buildbot.python.org/all/#/builders/185/builds/488

      test_current_task_no_running_loop_implicit (test.test_asyncio.test_tasks.CCurrentLoopTests) ... Warning -- threading_cleanup() failed to cleanup -1 threads (count: 0, dangling: 1)

    11. asvetlov commented on Jun 3, 2019

      @asvetlov
      Contributor

      Working on PR

    12. vstinner commented on Jun 3, 2019

      @vstinner
      MemberAuthor
    13. asvetlov commented on Jun 3, 2019

      @asvetlov
      Contributor

      We have two options:

      1. Apply bpo-37137: Close pid waiters on watcher.close() #13792 to wait for dangling threads
      2. Revert added watchers entirely

      What do you prefer?

    14. vstinner commented on Jun 3, 2019

      @vstinner
      MemberAuthor
      1. Revert added watchers entirely

      I prefer this option just because we must fix all bugs as soon as possible to get the beta1 released, and this bug is just one bug in a list of bugs.

      I might try to help you *later* to fix the change to prevent this bug.

    15. asvetlov commented on Jun 3, 2019

      @asvetlov
      Contributor

      Got you. #13793

    16. vstinner commented on Jun 4, 2019

      @vstinner
      MemberAuthor

      Thanks Andrew! Sorry that you had to revert your change :-(

      We can reconsider to merge again your change after beta1 (if our release manager is fine with that).

    17. vstinner commented on Jun 4, 2019

      @vstinner
      MemberAuthor

      The initial issue has been fixed.

      Let's continue the discussion on https://bugs.python.org/issue35621 to maybe reapply commit 13ed079.

    18. 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

      3.8 (EOL)tests

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions