mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-11-23 01:46:35 +03:00
Remove some redundant except
This commit is contained in:
parent
c9ea1bafc0
commit
df1dfdf8ea
|
@ -95,8 +95,6 @@ class TcpClient:
|
||||||
loop=self._loop
|
loop=self._loop
|
||||||
)
|
)
|
||||||
self._closed.clear()
|
self._closed.clear()
|
||||||
except asyncio.TimeoutError as e:
|
|
||||||
raise TimeoutError() from e
|
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
if e.errno in CONN_RESET_ERRNOS:
|
if e.errno in CONN_RESET_ERRNOS:
|
||||||
raise ConnectionResetError() from e
|
raise ConnectionResetError() from e
|
||||||
|
@ -137,7 +135,7 @@ class TcpClient:
|
||||||
if not self.is_connected:
|
if not self.is_connected:
|
||||||
raise self.SocketClosed()
|
raise self.SocketClosed()
|
||||||
if not done:
|
if not done:
|
||||||
raise TimeoutError()
|
raise asyncio.TimeoutError()
|
||||||
return done.pop().result()
|
return done.pop().result()
|
||||||
|
|
||||||
async def write(self, data):
|
async def write(self, data):
|
||||||
|
@ -147,12 +145,10 @@ class TcpClient:
|
||||||
"""
|
"""
|
||||||
if not self.is_connected:
|
if not self.is_connected:
|
||||||
raise ConnectionResetError('Not connected')
|
raise ConnectionResetError('Not connected')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
await self._wait_timeout_or_close(self.sock_sendall(data))
|
await self._wait_timeout_or_close(self.sock_sendall(data))
|
||||||
except self.SocketClosed:
|
|
||||||
raise ConnectionResetError('Socket has closed')
|
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
__log__.info('OSError "%s" while writing data', e)
|
|
||||||
if e.errno in CONN_RESET_ERRNOS:
|
if e.errno in CONN_RESET_ERRNOS:
|
||||||
raise ConnectionResetError() from e
|
raise ConnectionResetError() from e
|
||||||
else:
|
else:
|
||||||
|
@ -175,17 +171,13 @@ class TcpClient:
|
||||||
partial = await self._wait_timeout_or_close(
|
partial = await self._wait_timeout_or_close(
|
||||||
self.sock_recv(bytes_left)
|
self.sock_recv(bytes_left)
|
||||||
)
|
)
|
||||||
except TimeoutError as e:
|
except asyncio.TimeoutError:
|
||||||
if bytes_left < size:
|
if bytes_left < size:
|
||||||
__log__.warning(
|
__log__.warning(
|
||||||
'socket timeout "%s" when %d/%d had been received',
|
'Timeout when partial %d/%d had been received',
|
||||||
e, size - bytes_left, size
|
size - bytes_left, size
|
||||||
)
|
)
|
||||||
raise
|
raise
|
||||||
except self.SocketClosed:
|
|
||||||
raise ConnectionResetError(
|
|
||||||
'Socket has closed while reading data'
|
|
||||||
)
|
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
if e.errno in CONN_RESET_ERRNOS:
|
if e.errno in CONN_RESET_ERRNOS:
|
||||||
raise ConnectionResetError() from e
|
raise ConnectionResetError() from e
|
||||||
|
|
Loading…
Reference in New Issue
Block a user