mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-02-10 08:30:52 +03:00
Fix sleep on the wrong indent and handle CancelledError
This was causing a huge slow-down every time a request was received delaying all the subsequent incoming messages too
This commit is contained in:
parent
374f5e2aab
commit
7641ba2d32
|
@ -350,6 +350,8 @@ class MTProtoSender:
|
||||||
break
|
break
|
||||||
except asyncio.TimeoutError:
|
except asyncio.TimeoutError:
|
||||||
continue
|
continue
|
||||||
|
except asyncio.CancelledError:
|
||||||
|
return
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
__log__.warning('OSError while sending %s', e)
|
__log__.warning('OSError while sending %s', e)
|
||||||
except:
|
except:
|
||||||
|
@ -385,6 +387,8 @@ class MTProtoSender:
|
||||||
body = await self._connection.recv()
|
body = await self._connection.recv()
|
||||||
except asyncio.TimeoutError:
|
except asyncio.TimeoutError:
|
||||||
continue
|
continue
|
||||||
|
except asyncio.CancelledError:
|
||||||
|
return
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
if isinstance(e, ConnectionError):
|
if isinstance(e, ConnectionError):
|
||||||
__log__.info('Connection reset while receiving %s', e)
|
__log__.info('Connection reset while receiving %s', e)
|
||||||
|
@ -432,10 +436,12 @@ class MTProtoSender:
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
await self._process_message(message)
|
await self._process_message(message)
|
||||||
|
except asyncio.CancelledError:
|
||||||
|
return
|
||||||
except:
|
except:
|
||||||
__log__.exception('Unhandled exception while '
|
__log__.exception('Unhandled exception while '
|
||||||
'processing %s', message)
|
'processing %s', message)
|
||||||
await asyncio.sleep(1)
|
await asyncio.sleep(1)
|
||||||
|
|
||||||
# Response Handlers
|
# Response Handlers
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user