forked from goodboy/tractor
1
0
Fork 0

Tolerate non-decode-able bytes

drop_msgpack
Tyler Goodlet 2022-07-01 14:37:46 -04:00
parent 673c4a8c66
commit 5168700fbf
1 changed files with 6 additions and 2 deletions

View File

@ -185,11 +185,15 @@ class MsgpackTCPStream(MsgTransport):
# 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.
decoded_bytes = msg_bytes.decode() try:
data = msg_bytes.decode()
except UnicodeDecodeError:
data = msg_bytes
log.error( log.error(
'`msgspec` failed to decode!?\n' '`msgspec` failed to decode!?\n'
'dumping bytes:\n' 'dumping bytes:\n'
f'{decoded_bytes}' f'{data}'
) )
decodes_failed += 1 decodes_failed += 1
else: else: