mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-11-25 10:53:44 +03:00
Properly log RpcError with no parent request
This should get rid of the unexpected BufferError traceback.
This commit is contained in:
parent
0f5eeb29e7
commit
1af6d9a873
|
@ -592,12 +592,20 @@ class MTProtoSender:
|
||||||
# However receiving a File() with empty bytes is "common".
|
# However receiving a File() with empty bytes is "common".
|
||||||
# See #658, #759 and #958. They seem to happen in a container
|
# See #658, #759 and #958. They seem to happen in a container
|
||||||
# which contain the real response right after.
|
# which contain the real response right after.
|
||||||
try:
|
#
|
||||||
with BinaryReader(rpc_result.body) as reader:
|
# But, it might also happen that we get an *error* for no parent request.
|
||||||
if not isinstance(reader.tgread_object(), upload.File):
|
# If that's the case attempting to read from body which is None would fail with:
|
||||||
raise ValueError('Not an upload.File')
|
# "BufferError: No more data left to read (need 4, got 0: b''); last read None".
|
||||||
except (TypeNotFoundError, ValueError):
|
# This seems to be particularly common for "RpcError(error_code=-500, error_message='No workers running')".
|
||||||
self._log.info('Received response without parent request: %s', rpc_result.body)
|
if rpc_result.error:
|
||||||
|
self._log.info('Received error without parent request: %s', rpc_result.error)
|
||||||
|
else:
|
||||||
|
try:
|
||||||
|
with BinaryReader(rpc_result.body) as reader:
|
||||||
|
if not isinstance(reader.tgread_object(), upload.File):
|
||||||
|
raise ValueError('Not an upload.File')
|
||||||
|
except (TypeNotFoundError, ValueError):
|
||||||
|
self._log.info('Received response without parent request: %s', rpc_result.body)
|
||||||
return
|
return
|
||||||
|
|
||||||
if rpc_result.error:
|
if rpc_result.error:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user