Closed
Description
async_generator is really useful! But I see one surprising behavior. When I run this code:
import trio
from async_generator import async_generator, yield_
@async_generator
async def items():
for i in range(10):
await yield_(i)
async def main():
async for i in items():
if i > 4:
break
print(i)
if __name__ == '__main__':
trio.run(main)
I get the following exception:
Exception ignored in: <bound method AsyncGenerator.__del__ of <async_generator._impl.AsyncGenerator object at 0x110a9b908>>
Traceback (most recent call last):
File ".../python3.5/site-packages/async_generator/_impl.py", line 324, in __del__
.format(self._coroutine.cr_frame.f_code.co_name)
RuntimeError: partially-exhausted async_generator 'items' garbage collected
Is this expected? The same code using the Python 3.6 syntax does not print any exception. Thanks!
Metadata
Metadata
Assignees
Labels
No labels