mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-02-16 19:41:07 +03:00
Higher timeout and log them as warning if any data was received
This might be the cause for "number of retries reached 0" so more specific logging calls might be useful. If while reading a response it times out but some data had already been read, said data will be lost. The sequence of events that triggered reaching 0 retries was: - Sending requests with IDs XYZ - socket.timeout while reading - Items timed out. Retrying - Processing RPC result - Received response for XYZ - Lost request with ID XYZ
This commit is contained in:
parent
35eccc0ba3
commit
987cf41ec6
|
@ -153,7 +153,6 @@ class TcpClient:
|
|||
if self._socket is None:
|
||||
self._raise_connection_reset(None)
|
||||
|
||||
# TODO Remove the timeout from this method, always use previous one
|
||||
with BufferedWriter(BytesIO(), buffer_size=size) as buffer:
|
||||
bytes_left = size
|
||||
while bytes_left != 0:
|
||||
|
@ -162,7 +161,16 @@ class TcpClient:
|
|||
except socket.timeout as e:
|
||||
# These are somewhat common if the server has nothing
|
||||
# to send to us, so use a lower logging priority.
|
||||
__log__.debug('socket.timeout "%s" while reading data', e)
|
||||
if bytes_left < size:
|
||||
__log__.warning(
|
||||
'socket.timeout "%s" when %d/%d had been received',
|
||||
e, size - bytes_left, size
|
||||
)
|
||||
else:
|
||||
__log__.debug(
|
||||
'socket.timeout "%s" while reading data', e
|
||||
)
|
||||
|
||||
raise TimeoutError() from e
|
||||
except ConnectionError as e:
|
||||
__log__.info('ConnectionError "%s" while reading data', e)
|
||||
|
|
|
@ -170,7 +170,7 @@ class TelegramClient(TelegramBareClient):
|
|||
use_ipv6=False,
|
||||
proxy=None,
|
||||
update_workers=None,
|
||||
timeout=timedelta(seconds=5),
|
||||
timeout=timedelta(seconds=10),
|
||||
spawn_read_thread=True,
|
||||
report_errors=True,
|
||||
**kwargs):
|
||||
|
|
Loading…
Reference in New Issue
Block a user