Skip to content

Commit

Permalink
Merge pull request #63 from altendky/Emissions.send_channel
Browse files Browse the repository at this point in the history
Add Emissions.send_channel
  • Loading branch information
altendky authored Jul 3, 2020
2 parents 19954cd + 309e60d commit b745c20
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions qtrio/_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,17 +135,17 @@ class Emissions:
Attributes:
channel: A memory receive channel to be fed by signal emissions.
_aclose: The send channel's `.aclose()` method.
send_channel: A memory send channel collecting signal emissions.
"""

channel: trio.MemoryReceiveChannel
_aclose: typing.Callable[[], typing.Awaitable[typing.Any]]
send_channel: trio.MemorySendChannel

async def aclose(self):
"""Asynchronously close the send channel when signal emissions are no longer of
interest.
"""
return await self._aclose()
return await self.send_channel.aclose()


@async_generator.asynccontextmanager
Expand Down Expand Up @@ -184,7 +184,7 @@ def slot(*args, internal_signal=signal):

stack.enter_context(qtrio.connection(signal, slot))

yield Emissions(channel=receive_channel, aclose=send_channel.aclose)
yield Emissions(channel=receive_channel, send_channel=send_channel)


@async_generator.asynccontextmanager
Expand Down

0 comments on commit b745c20

Please sign in to comment.