It will be a very rare case — you need a generator that produces an infinite series of values with a try..finally block.
def gen():
async with cm_long_aexit():
yield 1
yield 2
yield 3
async for i in gen():
if i == 2: break
We can maintain a weak set of ‘aclose’ tasks in the event loop, and make it a public and documented property. That way you’ll be able to call gather() with a timeout on that list before closing the loop.