mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-11-22 09:26:37 +03:00
Add timeout parameter on TcpClient.connect() too
This commit is contained in:
parent
e4fbd87c75
commit
843c16215c
|
@ -30,9 +30,12 @@ class TcpClient:
|
|||
else: # tuple, list, etc.
|
||||
self._socket.set_proxy(*self._proxy)
|
||||
|
||||
def connect(self, ip, port):
|
||||
"""Connects to the specified IP and port number"""
|
||||
def connect(self, ip, port, timeout):
|
||||
"""Connects to the specified IP and port number.
|
||||
'timeout' must be given in seconds
|
||||
"""
|
||||
if not self.connected:
|
||||
self._socket.settimeout(timeout)
|
||||
self._socket.connect((ip, port))
|
||||
self._socket.setblocking(False)
|
||||
self.connected = True
|
||||
|
|
|
@ -18,7 +18,8 @@ class TcpTransport:
|
|||
def connect(self):
|
||||
"""Connects to the specified IP address and port"""
|
||||
self.send_counter = 0
|
||||
self.tcp_client.connect(self.ip, self.port)
|
||||
self.tcp_client.connect(self.ip, self.port,
|
||||
timeout=round(self.timeout.seconds))
|
||||
|
||||
def is_connected(self):
|
||||
return self.tcp_client.connected
|
||||
|
|
Loading…
Reference in New Issue
Block a user