Closed byllyfish closed 1 year ago
Here's a construction of chain
that seems to work better:
class _Chain1:
def __call__(self, *iterables):
async def impl():
for iterable in iterables:
async with asl.scoped_iter(iterable) as iterator:
async for item in iterator:
yield item
return impl()
# Add other async methods here...
chain = _Chain1()
It looks like this is due to a missing aclose
(which a class implementation needs explicitly). Thanks for the report.
The fix you committed passes all my tests. Thanks!
There is a subtle change in behavior introduced in the recent changes to
chain()
. Chain's iterator appears to be escaping from its "scope" when it is interrupted.Here is an example program that produces different output. I'm using Python 3.11.2, but I don't think the Python version makes much difference.
asyncstdlib 3.10.5 (correct output)
asyncstdlib 3.10.6 (incorrect output)