Skip to content

Commit

Permalink
Allow up to 4 msgpsec decode failures
Browse files Browse the repository at this point in the history
  • Loading branch information
goodboy committed May 31, 2022
1 parent d3f763b commit 658c760
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions tractor/_ipc.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ async def _iter_packets(self) -> AsyncGenerator[dict, None]:
'''
import msgspec # noqa
last_decode_failed: bool = False
decodes_failed: int = 0

while True:
try:
Expand Down Expand Up @@ -268,12 +268,16 @@ async def _iter_packets(self) -> AsyncGenerator[dict, None]:
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

Expand Down

0 comments on commit 658c760

Please sign in to comment.