Skip to content

Refleaks reported for test_external_inspection.test_running_task_with_non_native_coroutine #162616

Done

Description

@encukou

The test added in gh-159679 is reported as leaking when run with -R:.

Creating a task checks if the argument is a coroutine. For non-native coroutines, this adds the type (the test's Wrapper) to _asyncio's iscoroutine_typecache. Another check adds it to asyncio.coroutines._iscoroutine_typecache.
Both caches are capped at 100 entries, so refleak tests report a reference leak unless you run 100+ warmup runs.

$ ./python -m test test_external_inspection -R100: -m test_running_task_with_non_native_coroutine
Using random seed: 1957203783
0:00:00 load avg: 1.98 mem:   22.2 MiB Run 1 test sequentially in a single process
0:00:00 load avg: 1.98 mem:   22.2 MiB [1/1] test_external_inspection
beginning 104 repetitions. Showing number of leaks (. for 0 or less, X for 10 or more)
1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890:1234
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX ....

Example Buildbot failure: https://buildbot.python.org/#/builders/320/builds/4896

Linked PRs

Activity

  1. self-assigned this
    on Nov 25, 2026
  2. added
    tests
    on Nov 25, 2026
  3. added
    type-bug
    on Nov 25, 2026
  4. added 3 commits that reference this issue on Nov 25, 2026
  5. asvetlov commented on Nov 26, 2026

    @asvetlov
    Contributor

    Fixed

  6. moved this from Todo to Done in asyncioon Nov 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

teststopic-asynciotopic-profilingtype-bug

Projects

  • Status
    Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions