mirror of
				https://github.com/LonamiWebs/Telethon.git
				synced 2025-10-30 23:47:33 +03:00 
			
		
		
		
	Pump up default timeout from 5 to 10s
This commit is contained in:
		
							parent
							
								
									d18ee9ecc5
								
							
						
					
					
						commit
						226c35ff8f
					
				|  | @ -107,7 +107,7 @@ class TelegramBaseClient(abc.ABC): | |||
|                  connection=ConnectionTcpFull, | ||||
|                  use_ipv6=False, | ||||
|                  proxy=None, | ||||
|                  timeout=timedelta(seconds=5), | ||||
|                  timeout=timedelta(seconds=10), | ||||
|                  report_errors=True, | ||||
|                  device_model=None, | ||||
|                  system_version=None, | ||||
|  |  | |||
|  | @ -11,7 +11,6 @@ import asyncio | |||
| import errno | ||||
| import logging | ||||
| import socket | ||||
| from datetime import timedelta | ||||
| from io import BytesIO | ||||
| 
 | ||||
| CONN_RESET_ERRNOS = { | ||||
|  | @ -38,7 +37,7 @@ class TcpClient: | |||
|     class SocketClosed(ConnectionError): | ||||
|         pass | ||||
| 
 | ||||
|     def __init__(self, *, loop, proxy=None, timeout=timedelta(seconds=5)): | ||||
|     def __init__(self, *, loop, timeout, proxy=None): | ||||
|         """ | ||||
|         Initializes the TCP client. | ||||
| 
 | ||||
|  |  | |||
|  | @ -11,7 +11,6 @@ Said subclasses need not to worry about reconnecting either, and | |||
| should let the errors propagate instead. | ||||
| """ | ||||
| import abc | ||||
| from datetime import timedelta | ||||
| 
 | ||||
| 
 | ||||
| class Connection(abc.ABC): | ||||
|  | @ -21,13 +20,13 @@ class Connection(abc.ABC): | |||
|     Subclasses should implement the actual protocol | ||||
|     being used when encoding/decoding messages. | ||||
|     """ | ||||
|     def __init__(self, *, loop, proxy=None, timeout=timedelta(seconds=5)): | ||||
|     def __init__(self, *, loop, timeout, proxy=None): | ||||
|         """ | ||||
|         Initializes a new connection. | ||||
| 
 | ||||
|         :param loop: the event loop to be used. | ||||
|         :param proxy: whether to use a proxy or not. | ||||
|         :param timeout: timeout to be used for all operations. | ||||
|         :param proxy: whether to use a proxy or not. | ||||
|         """ | ||||
|         self._loop = loop | ||||
|         self._proxy = proxy | ||||
|  |  | |||
|  | @ -1,6 +1,5 @@ | |||
| import errno | ||||
| import struct | ||||
| from datetime import timedelta | ||||
| from zlib import crc32 | ||||
| 
 | ||||
| from .common import Connection | ||||
|  | @ -13,11 +12,11 @@ class ConnectionTcpFull(Connection): | |||
|     Default Telegram mode. Sends 12 additional bytes and | ||||
|     needs to calculate the CRC value of the packet itself. | ||||
|     """ | ||||
|     def __init__(self, *, loop, proxy=None, timeout=timedelta(seconds=5)): | ||||
|         super().__init__(loop=loop, proxy=proxy, timeout=timeout) | ||||
|     def __init__(self, *, loop, timeout, proxy=None): | ||||
|         super().__init__(loop=loop, timeout=timeout, proxy=proxy) | ||||
|         self._send_counter = 0 | ||||
|         self.conn = TcpClient( | ||||
|             proxy=self._proxy, timeout=self._timeout, loop=self._loop | ||||
|             timeout=self._timeout, loop=self._loop, proxy=self._proxy | ||||
|         ) | ||||
|         self.read = self.conn.read | ||||
|         self.write = self.conn.write | ||||
|  |  | |||
|  | @ -1,8 +1,7 @@ | |||
| import os | ||||
| from datetime import timedelta | ||||
| 
 | ||||
| from .tcpfull import ConnectionTcpFull | ||||
| from .tcpabridged import ConnectionTcpAbridged | ||||
| from .tcpfull import ConnectionTcpFull | ||||
| from ...crypto import AESModeCTR | ||||
| 
 | ||||
| 
 | ||||
|  | @ -12,8 +11,8 @@ class ConnectionTcpObfuscated(ConnectionTcpAbridged): | |||
|     every message with a randomly generated key using the | ||||
|     AES-CTR mode so the packets are harder to discern. | ||||
|     """ | ||||
|     def __init__(self, *, loop, proxy=None, timeout=timedelta(seconds=5)): | ||||
|         super().__init__(loop=loop, proxy=proxy, timeout=timeout) | ||||
|     def __init__(self, *, loop, timeout, proxy=None): | ||||
|         super().__init__(loop=loop, timeout=timeout, proxy=proxy) | ||||
|         self._aes_encrypt, self._aes_decrypt = None, None | ||||
|         self.read = lambda s: self._aes_decrypt.encrypt(self.conn.read(s)) | ||||
|         self.write = lambda d: self.conn.write(self._aes_encrypt.encrypt(d)) | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	Block a user