forked from goodboy/tractor
Allow up to 4 `msgpsec` decode failures
parent
414c59cca6
commit
b3fd5da1be
|
@ -231,7 +231,7 @@ class MsgspecTCPStream(MsgpackTCPStream):
|
||||||
|
|
||||||
'''
|
'''
|
||||||
import msgspec # noqa
|
import msgspec # noqa
|
||||||
last_decode_failed: bool = False
|
decodes_failed: int = 0
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
|
@ -268,12 +268,16 @@ class MsgspecTCPStream(MsgpackTCPStream):
|
||||||
msgspec.DecodeError,
|
msgspec.DecodeError,
|
||||||
UnicodeDecodeError,
|
UnicodeDecodeError,
|
||||||
):
|
):
|
||||||
if not last_decode_failed:
|
if decodes_failed < 4:
|
||||||
# ignore decoding errors for now and assume they have to
|
# ignore decoding errors for now and assume they have to
|
||||||
# do with a channel drop - hope that receiving from the
|
# do with a channel drop - hope that receiving from the
|
||||||
# channel will raise an expected error and bubble up.
|
# channel will raise an expected error and bubble up.
|
||||||
log.error('`msgspec` failed to decode!?')
|
log.error(
|
||||||
last_decode_failed = True
|
'`msgspec` failed to decode!?\n'
|
||||||
|
'dumping bytes:\n'
|
||||||
|
f'{msg_bytes}'
|
||||||
|
)
|
||||||
|
decodes_failed += 1
|
||||||
else:
|
else:
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue