async-cleanup-registered-synchronously
Do not register a proven async cleanup function with ExitStack.callback.
Why
The synchronous callback API discards the returned coroutine without awaiting it, so the cleanup body never runs.
Fix
Use AsyncExitStack and register the coroutine function with push_async_callback.
Examples
from contextlib import AsyncExitStack
async def close(): await release()
async def run(): async with AsyncExitStack() as stack: stack.callback(close)from contextlib import AsyncExitStack
async def close(): await release()
async def run(): async with AsyncExitStack() as stack: stack.push_async_callback(close)