Wrap `open_autorecon_ws()` body for comms failures
Add outer `try/except` around the nursery block in `open_autorecon_ws()` to catch any `NoBsWs.recon_errors` that escape the inner reconnect loop, logging a warning instead of propagating. Also, - correct `NoBsWs.recon_errors` typing to `tuple[Type[Exception]]`. (this commit msg was generated in some part by [`claude-code`][claude-code-gh]) [claude-code-gh]: https://github.com/anthropics/claude-codetpt_closed_and_finally_footguns
parent
6f390dc88c
commit
3d83b61f3f
|
|
@ -31,6 +31,7 @@ from typing import (
|
|||
AsyncContextManager,
|
||||
AsyncGenerator,
|
||||
Iterable,
|
||||
Type,
|
||||
)
|
||||
import json
|
||||
|
||||
|
|
@ -67,7 +68,7 @@ class NoBsWs:
|
|||
|
||||
'''
|
||||
# apparently we can QoS for all sorts of reasons..so catch em.
|
||||
recon_errors = (
|
||||
recon_errors: tuple[Type[Exception]] = (
|
||||
ConnectionClosed,
|
||||
DisconnectionTimeout,
|
||||
ConnectionRejected,
|
||||
|
|
@ -370,6 +371,7 @@ async def open_autorecon_ws(
|
|||
rcv: trio.MemoryReceiveChannel
|
||||
snd, rcv = trio.open_memory_channel(616)
|
||||
|
||||
try:
|
||||
async with (
|
||||
tractor.trionics.collapse_eg(),
|
||||
trio.open_nursery() as tn
|
||||
|
|
@ -397,6 +399,12 @@ async def open_autorecon_ws(
|
|||
finally:
|
||||
tn.cancel_scope.cancel()
|
||||
|
||||
except NoBsWs.recon_errors as con_err:
|
||||
log.warning(
|
||||
f'Entire ws-channel disconnect due to,\n'
|
||||
f'con_err: {con_err!r}\n'
|
||||
)
|
||||
|
||||
|
||||
'''
|
||||
JSONRPC response-request style machinery for transparent multiplexing
|
||||
|
|
|
|||
Loading…
Reference in New Issue