diff --git a/qtrio/_core.py b/qtrio/_core.py index a8d4fcd6..5105d803 100644 --- a/qtrio/_core.py +++ b/qtrio/_core.py @@ -147,6 +147,9 @@ async def aclose(self): """ return await self.send_channel.aclose() + def __aiter__(self): + return self.channel.__aiter__() + @async_generator.asynccontextmanager async def open_emissions_channel( diff --git a/qtrio/_tests/test_core.py b/qtrio/_tests/test_core.py index 0c4de7a6..76e0f7da 100644 --- a/qtrio/_tests/test_core.py +++ b/qtrio/_tests/test_core.py @@ -726,7 +726,7 @@ async def test(request): await emissions.aclose() async with emissions.channel: - async for emission in emissions.channel: + async for emission in emissions: [value] = emission.args results.append(value) @@ -765,7 +765,7 @@ async def test(request): await emissions.aclose() async with emissions.channel: - async for emission in emissions.channel: + async for emission in emissions: [value] = emission.args results.append(value) diff --git a/qtrio/examples/_tests/test_crossingpaths.py b/qtrio/examples/_tests/test_crossingpaths.py index 60923dc0..2f0e494b 100644 --- a/qtrio/examples/_tests/test_crossingpaths.py +++ b/qtrio/examples/_tests/test_crossingpaths.py @@ -27,7 +27,7 @@ def setText(self, *args, **kwargs): async def user(): async with emissions.channel: - async for emission in emissions.channel: + async for emission in emissions: [text] = emission.args results.append(text) diff --git a/qtrio/examples/emissions.py b/qtrio/examples/emissions.py index ed512179..82681dd5 100644 --- a/qtrio/examples/emissions.py +++ b/qtrio/examples/emissions.py @@ -108,7 +108,7 @@ async def main(window=None): window.show() async with emissions.channel: - async for emission in emissions.channel: + async for emission in emissions: if emission.is_from(window.decrement.clicked): window.decrement_count() elif emission.is_from(window.increment.clicked):