diff --git a/qtrio/_core.py b/qtrio/_core.py index 3d744e1f..fdcb200c 100644 --- a/qtrio/_core.py +++ b/qtrio/_core.py @@ -159,6 +159,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 226db8ac..4a9ea9e9 100644 --- a/qtrio/_tests/test_core.py +++ b/qtrio/_tests/test_core.py @@ -735,7 +735,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) @@ -774,7 +774,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 8653ed6a..62ed9cf7 100644 --- a/qtrio/examples/_tests/test_crossingpaths.py +++ b/qtrio/examples/_tests/test_crossingpaths.py @@ -26,7 +26,7 @@ def setText(self, *args, **kwargs): results = [] async def user(): - 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 45efad3d..191c3acf 100644 --- a/qtrio/examples/emissions.py +++ b/qtrio/examples/emissions.py @@ -107,7 +107,7 @@ async def main(window=None): async with qtrio.enter_emissions_channel(signals=signals) as emissions: window.show() - 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):