Skip to content

Commit

Permalink
First pass at iterable Emissions objects
Browse files Browse the repository at this point in the history
Fixes #67.
  • Loading branch information
altendky committed Jul 4, 2020
1 parent a6b5d78 commit b791c29
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
3 changes: 3 additions & 0 deletions qtrio/_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions qtrio/_tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion qtrio/examples/_tests/test_crossingpaths.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion qtrio/examples/emissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit b791c29

Please sign in to comment.