Baboso! fix `chan.send(None)` indent..

ctx_cancel_semantics_and_overruns_REVERSED_FACEPALM
Tyler Goodlet 2024-02-19 14:41:03 -05:00
parent 6a303358df
commit 4b0aa5e379
1 changed files with 24 additions and 15 deletions

View File

@ -1047,23 +1047,32 @@ class Actor:
db_cs.cancel() db_cs.cancel()
# XXX: is this necessary (GC should do it)? # XXX: is this necessary (GC should do it)?
if chan.connected(): # XXX WARNING XXX
# if the channel is still connected it may mean the far # Be AWARE OF THE INDENT LEVEL HERE
# end has not closed and we may have gotten here due to # -> ONLY ENTER THIS BLOCK WHEN ._peers IS
# an error and so we should at least try to terminate # EMPTY!!!!
# the channel from this end gracefully. if (
not self._peers
and chan.connected()
):
# if the channel is still connected it may mean the far
# end has not closed and we may have gotten here due to
# an error and so we should at least try to terminate
# the channel from this end gracefully.
log.runtime(
'Terminating channel with `None` setinel msg\n'
f'|_{chan}\n'
)
try:
# send a msg loop terminate sentinel
await chan.send(None)
log.runtime(f"Disconnecting channel {chan}") # XXX: do we want this?
try: # causes "[104] connection reset by peer" on other end
# send a msg loop terminate sentinel # await chan.aclose()
await chan.send(None)
# XXX: do we want this? except trio.BrokenResourceError:
# causes "[104] connection reset by peer" on other end log.runtime(f"Channel {chan.uid} was already closed")
# await chan.aclose()
except trio.BrokenResourceError:
log.runtime(f"Channel {chan.uid} was already closed")
async def _push_result( async def _push_result(
self, self,