Skip to content

gh-162616: Clear asyncio's iscoroutine_typecaches between refleak tests - #162617

Merged
asvetlov merged 2 commits into
python:mainfrom
encukou:clear-iscoroutine_typecaches
Nov 25, 2026
Merged

asvetlov merged 2 commits into
python:mainfrom
encukou:clear-iscoroutine_typecaches

Conversation

@encukou

@encukou encukou commented Nov 25, 2026 •

Copy link
Copy Markdown
Member

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.

Clear both caches in libregrtest.utils.clear_caches.

…leak tests

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.

Clear both caches in `libregrtest.utils.clear_caches`.
Comment thread Lib/test/libregrtest/utils.py Resolved
Comment thread Lib/test/libregrtest/utils.py Resolved
Comment thread Modules/_asynciomodule.c Resolved

@asvetlov asvetlov left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@asvetlov
asvetlov merged commit 233b95c into python:main Nov 25, 2026
77 checks passed
@encukou
encukou deleted the clear-iscoroutine_typecaches branch November 25, 2026 16:34
@asvetlov asvetlov added needs backport to 3.14 bugs and security fixes needs backport to 3.15 bugs and security fixes and removed needs backport to 3.14 bugs and security fixes needs backport to 3.15 bugs and security fixes labels Nov 26, 2026
@miss-islington-app

Copy link
Copy Markdown

Thanks @encukou for the PR, and @asvetlov for merging it 🌮🎉.. I'm working now to backport this PR to: 3.14.
🐍🍒⛏🤖

@miss-islington-app

Copy link
Copy Markdown

Thanks @encukou for the PR, and @asvetlov for merging it 🌮🎉.. I'm working now to backport this PR to: 3.15.
🐍🍒⛏🤖

@miss-islington-app

Copy link
Copy Markdown

Sorry, @encukou and @asvetlov, I could not cleanly backport this to 3.14 due to a conflict.

Please backport manually with cherry_picker, see the devguide for more information.

cherry_picker 233b95c00bd70f0bd60838b1cfc639996f1476a9 3.14

@miss-islington-app

Copy link
Copy Markdown

Sorry, @encukou and @asvetlov, I could not cleanly backport this to 3.15 due to a conflict.

Please backport manually with cherry_picker, see the devguide for more information.

cherry_picker 233b95c00bd70f0bd60838b1cfc639996f1476a9 3.15

@bedevere-app

bedevere-app Bot commented Nov 26, 2026

Copy link
Copy Markdown

GH-162682 is a backport of this pull request to the 3.15 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.15 bugs and security fixes label Nov 26, 2026
@bedevere-app

bedevere-app Bot commented Nov 26, 2026

Copy link
Copy Markdown

GH-162683 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label Nov 26, 2026
asvetlov added a commit that referenced this pull request Nov 26, 2026
…fleak tests (GH-162617) (#162682)

* gh-162616: Clear asyncio's `iscoroutine_typecache`s between refleak tests

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.

Clear both caches in `libregrtest.utils.clear_caches`.

* Apply suggestions from code review

---------


(cherry picked from commit 233b95c)

Co-authored-by: Petr Viktorin <encukou@gmail.com>
asvetlov added a commit that referenced this pull request Nov 26, 2026
…fleak tests (GH-162617) (#162683)

* gh-162616: Clear asyncio's `iscoroutine_typecache`s between refleak tests

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.

Clear both caches in `libregrtest.utils.clear_caches`.

* Apply suggestions from code review

---------


(cherry picked from commit 233b95c)

Co-authored-by: Petr Viktorin <encukou@gmail.com>
@bedevere-bot

Copy link
Copy Markdown

⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️

Hi! The buildbot AMD64 Fedora Stable 3.15 (tier-1) has failed when building commit 5abbc18.

What do you need to do:

  1. Don't panic.
  2. Check the buildbot page in the devguide if you don't know what the buildbots are or how they work.
  3. Go to the page of the buildbot that failed (https://buildbot.python.org/#/builders/2058/builds/640) and take a look at the build logs.
  4. Check if the failure is related to this commit (5abbc18) or if it is a false positive.
  5. If the failure is related to this commit, please, reflect that on the issue and make a new Pull Request with a fix.

You can take a look at the buildbot page here:

https://buildbot.python.org/#/builders/2058/builds/640

Summary of the results of the build (if available):

Click to see traceback logs
Note: switching to '5abbc189bb31f4d5db6300d1c61a33c248ad36e5'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:

  git switch -c <new-branch-name>

Or undo this operation with:

  git switch -

Turn off this advice by setting config variable advice.detachedHead to false

HEAD is now at 5abbc189bb31f [3.15] gh-162616: Clear asyncio's `iscoroutine_typecache`s between refleak tests (GH-162617) (#162682)
Switched to and reset branch '3.15'

/tmp/ccolN8k1.s: Assembler messages:
/tmp/ccolN8k1.s: Fatal error: can't write 2490 bytes to section .gnu.debuglto_.debug_info of Modules/arraymodule.o: 'No space left on device'
/tmp/ccolN8k1.s: Fatal error: Modules/arraymodule.o: No such file or directory
make: *** [Makefile:3731: Modules/arraymodule.o] Error 1
make: *** Waiting for unfinished jobs....
/tmp/ccTK0Dnw.s: Assembler messages:
/tmp/ccTK0Dnw.s: Fatal error: can't write 845 bytes to section .gnu.lto_.inline.c89fe1bf6383e6fd of Modules/_remote_debugging/code_objects.o: 'No space left on device'
/tmp/ccTK0Dnw.s: Fatal error: Modules/_remote_debugging/code_objects.o: No such file or directory
make: *** [Makefile:3755: Modules/_remote_debugging/code_objects.o] Error 1
/tmp/cckXIaYS.s: Assembler messages:
/tmp/cckXIaYS.s: Fatal error: can't write 1755 bytes to section .gnu.debuglto_.debug_line_str of Modules/_remote_debugging/object_reading.o: 'No space left on device'
/tmp/cckXIaYS.s: Fatal error: Modules/_remote_debugging/object_reading.o: No such file or directory
make: *** [Makefile:3754: Modules/_remote_debugging/object_reading.o] Error 1
/tmp/ccOTSb45.s: Assembler messages:
/tmp/ccOTSb45.s: Fatal error: can't write 3912 bytes to section .gnu.debuglto_.debug_info of Modules/_sre/sre.o: 'No space left on device'
/tmp/ccOTSb45.s: Fatal error: Modules/_sre/sre.o: No such file or directory
make: *** [Makefile:4025: Modules/_sre/sre.o] Error 1
/tmp/ccureR6C.s: Assembler messages:
/tmp/ccureR6C.s: Fatal error: can't write 957 bytes to section .gnu.lto_PyList_GET_SIZE.2.d4653b599edd1c49 of Modules/_remote_debugging/frame_cache.o: 'No space left on device'
/tmp/ccureR6C.s: Fatal error: Modules/_remote_debugging/frame_cache.o: No such file or directory
make: *** [Makefile:3757: Modules/_remote_debugging/frame_cache.o] Error 1
/tmp/ccJhAVmT.s: Assembler messages:
/tmp/ccJhAVmT.s: Fatal error: can't write 3911 bytes to section .gnu.debuglto_.debug_str of Modules/_remote_debugging/frames.o: 'No space left on device'
/tmp/ccJhAVmT.s: Fatal error: Modules/_remote_debugging/frames.o: No such file or directory
make: *** [Makefile:3756: Modules/_remote_debugging/frames.o] Error 1
/tmp/ccS3x2yt.s: Assembler messages:
/tmp/ccS3x2yt.s: Fatal error: can't write 3911 bytes to section .gnu.debuglto_.debug_str of Modules/_remote_debugging/threads.o: 'No space left on device'
/tmp/ccS3x2yt.s: Fatal error: Modules/_remote_debugging/threads.o: No such file or directory
make: *** [Makefile:3758: Modules/_remote_debugging/threads.o] Error 1
/tmp/ccgruWAg.s: Assembler messages:
/tmp/ccgruWAg.s: Fatal error: can't write 3912 bytes to section .gnu.debuglto_.debug_info of Modules/_remote_debugging/module.o: 'No space left on device'
/tmp/ccgruWAg.s: Fatal error: Modules/_remote_debugging/module.o: No such file or directory
make: *** [Makefile:3752: Modules/_remote_debugging/module.o] Error 1
/tmp/ccUdGON1.s: Assembler messages:
/tmp/ccUdGON1.s: Fatal error: can't write 3911 bytes to section .gnu.debuglto_.debug_str of Modules/_remote_debugging/asyncio.o: 'No space left on device'
/tmp/ccUdGON1.s: Fatal error: Modules/_remote_debugging/asyncio.o: No such file or directory
make: *** [Makefile:3759: Modules/_remote_debugging/asyncio.o] Error 1
/tmp/cc3ZqKbW.s: Assembler messages:
/tmp/cc3ZqKbW.s: Fatal error: can't write 3912 bytes to section .gnu.debuglto_.debug_info of Modules/_pickle.o: 'No space left on device'
/tmp/cc3ZqKbW.s: Fatal error: Modules/_pickle.o: No such file or directory
make: *** [Makefile:3746: Modules/_pickle.o] Error 1

@bedevere-bot

Copy link
Copy Markdown

⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️

Hi! The buildbot AMD64 Fedora Stable Clang 3.15 (tier-2) has failed when building commit 5abbc18.

What do you need to do:

  1. Don't panic.
  2. Check the buildbot page in the devguide if you don't know what the buildbots are or how they work.
  3. Go to the page of the buildbot that failed (https://buildbot.python.org/#/builders/2021/builds/570) and take a look at the build logs.
  4. Check if the failure is related to this commit (5abbc18) or if it is a false positive.
  5. If the failure is related to this commit, please, reflect that on the issue and make a new Pull Request with a fix.

You can take a look at the buildbot page here:

https://buildbot.python.org/#/builders/2021/builds/570

Summary of the results of the build (if available):

Click to see traceback logs
Note: switching to '5abbc189bb31f4d5db6300d1c61a33c248ad36e5'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:

  git switch -c <new-branch-name>

Or undo this operation with:

  git switch -

Turn off this advice by setting config variable advice.detachedHead to false

HEAD is now at 5abbc189bb31f [3.15] gh-162616: Clear asyncio's `iscoroutine_typecache`s between refleak tests (GH-162617) (#162682)
Switched to and reset branch '3.15'

rror: unable to open output file 'Python/pylifecycle.o': 'No space left on device'
1 error generated.
make: *** [Makefile:3440: Python/pylifecycle.o] Error 1
make: *** Waiting for unfinished jobs....
rror: unable to open output file 'Python/remote_debugging.o': 'No space left on device'
1 error generated.
rror: unable to open output file 'Python/dtoa.o': 'No space left on device'
1 error generated.
make: *** [Makefile:3440: Python/remote_debugging.o] Error 1
make: *** [Makefile:3447: Python/dtoa.o] Error 1
rror: unable to open output file 'Modules/gcmodule.o': 'No space left on device'
1 error generated.
make: *** [Makefile:3440: Modules/gcmodule.o] Error 1
rror: unable to open output file 'Modules/main.o': 'No space left on device'
1 error generated.
make: *** [Makefile:3440: Modules/main.o] Error 1
rror: unable to open output file 'Modules/atexitmodule.o': 'No space left on device'
1 error generated.
make: *** [Makefile:3995: Modules/atexitmodule.o] Error 1
rror: unable to open output file 'Modules/faulthandler.o': 'No space left on device'
1 error generated.
make: *** [Makefile:3997: Modules/faulthandler.o] Error 1
rror: unable to open output file 'Modules/_asynciomodule.o': 'No space left on device'
1 error generated.
make: *** [Makefile:3993: Modules/_asynciomodule.o] Error 1
rror: unable to open output file 'Modules/_testinternalcapi/interpreter.o': 'No space left on device'
1 error generated.
make: *** [Makefile:3899: Modules/_testinternalcapi/interpreter.o] Error 1
rror: unable to open output file 'Python/ceval.o': 'No space left on device'
1 error generated.
make: *** [Makefile:3450: Python/ceval.o] Error 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants