forked from goodboy/tractor
Drop `Channel.aiter_recv()`
Internalize the implementation of this and expect client code to iterate the `Channel` directly. Resolves #16reg_with_uid
parent
bd14cbe082
commit
758fbc6790
|
@ -278,7 +278,7 @@ class Actor:
|
||||||
# worked out we'll likely want to use that!
|
# worked out we'll likely want to use that!
|
||||||
log.debug(f"Entering msg loop for {chan} from {chan.uid}")
|
log.debug(f"Entering msg loop for {chan} from {chan.uid}")
|
||||||
try:
|
try:
|
||||||
async for msg in chan.aiter_recv():
|
async for msg in chan:
|
||||||
if msg is None: # terminate sentinel
|
if msg is None: # terminate sentinel
|
||||||
log.debug(
|
log.debug(
|
||||||
f"Cancelling all tasks for {chan} from {chan.uid}")
|
f"Cancelling all tasks for {chan} from {chan.uid}")
|
||||||
|
|
|
@ -87,6 +87,7 @@ class Channel:
|
||||||
self._destaddr = destaddr or self.squeue.raddr
|
self._destaddr = destaddr or self.squeue.raddr
|
||||||
# set after handshake - always uid of far end
|
# set after handshake - always uid of far end
|
||||||
self.uid = None
|
self.uid = None
|
||||||
|
self._agen = self._aiter_recv()
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
if self.squeue:
|
if self.squeue:
|
||||||
|
@ -134,8 +135,8 @@ class Channel:
|
||||||
async def __aexit__(self, *args):
|
async def __aexit__(self, *args):
|
||||||
await self.aclose(*args)
|
await self.aclose(*args)
|
||||||
|
|
||||||
async def __aiter__(self):
|
def __aiter__(self):
|
||||||
return self.aiter_recv()
|
return self._agen
|
||||||
|
|
||||||
async def _reconnect(self):
|
async def _reconnect(self):
|
||||||
"""Handle connection failures by polling until a reconnect can be
|
"""Handle connection failures by polling until a reconnect can be
|
||||||
|
@ -166,7 +167,7 @@ class Channel:
|
||||||
" for re-establishment")
|
" for re-establishment")
|
||||||
await trio.sleep(1)
|
await trio.sleep(1)
|
||||||
|
|
||||||
async def aiter_recv(self):
|
async def _aiter_recv(self):
|
||||||
"""Async iterate items from underlying stream.
|
"""Async iterate items from underlying stream.
|
||||||
"""
|
"""
|
||||||
while True:
|
while True:
|
||||||
|
|
Loading…
Reference in New Issue