From b3fd5da1bebea4e2293879484e512519205ae29f Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Tue, 31 May 2022 12:19:29 -0400 Subject: [PATCH] Allow up to 4 `msgpsec` decode failures --- tractor/_ipc.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tractor/_ipc.py b/tractor/_ipc.py index e7e8f5e..0cfff7f 100644 --- a/tractor/_ipc.py +++ b/tractor/_ipc.py @@ -231,7 +231,7 @@ class MsgspecTCPStream(MsgpackTCPStream): ''' import msgspec # noqa - last_decode_failed: bool = False + decodes_failed: int = 0 while True: try: @@ -268,12 +268,16 @@ class MsgspecTCPStream(MsgpackTCPStream): msgspec.DecodeError, UnicodeDecodeError, ): - if not last_decode_failed: + if decodes_failed < 4: # ignore decoding errors for now and assume they have to # do with a channel drop - hope that receiving from the # channel will raise an expected error and bubble up. - log.error('`msgspec` failed to decode!?') - last_decode_failed = True + log.error( + '`msgspec` failed to decode!?\n' + 'dumping bytes:\n' + f'{msg_bytes}' + ) + decodes_failed += 1 else: raise