Remove empty except (#887)

This commit is contained in:
josephbiko 2018-07-09 20:54:43 +02:00 committed by Lonami
parent 4328663c78
commit e6981e7676
4 changed files with 17 additions and 8 deletions

View File

@ -32,6 +32,6 @@ times, in this case, ``22222`` so we can hardcode that:
client = TelegramClient(None, api_id, api_hash) client = TelegramClient(None, api_id, api_hash)
client.session.set_dc(2, '149.154.167.40', 80) client.session.set_dc(2, '149.154.167.40', 80)
loop.run_until_complete(client.start( client.start(
phone='9996621234', code_callback=lambda: '22222' phone='9996621234', code_callback=lambda: '22222'
)) )

View File

@ -210,7 +210,10 @@ class UpdateMethods(UserMethods):
continue # We actually just want to act upon timeout continue # We actually just want to act upon timeout
except asyncio.TimeoutError: except asyncio.TimeoutError:
pass pass
except: except asyncio.CancelledError:
await self.disconnect()
return
except Exception as e:
continue # Any disconnected exception should be ignored continue # Any disconnected exception should be ignored
# We also don't really care about their result. # We also don't really care about their result.
@ -273,7 +276,7 @@ class UpdateMethods(UserMethods):
type(event).__name__) type(event).__name__)
) )
break break
except: except Exception:
__log__.exception('Unhandled exception on {}' __log__.exception('Unhandled exception on {}'
.format(callback.__name__)) .format(callback.__name__))

View File

@ -36,7 +36,7 @@ def report_error(code, message, report_method):
) )
url.read() url.read()
url.close() url.close()
except: except Exception as e:
"We really don't want to crash when just reporting an error" "We really don't want to crash when just reporting an error"

View File

@ -386,6 +386,7 @@ class MTProtoSender:
except asyncio.TimeoutError: except asyncio.TimeoutError:
continue continue
except asyncio.CancelledError: except asyncio.CancelledError:
await self.disconnect()
return return
except Exception as e: except Exception as e:
if isinstance(e, ConnectionError): if isinstance(e, ConnectionError):
@ -425,6 +426,7 @@ class MTProtoSender:
except asyncio.TimeoutError: except asyncio.TimeoutError:
continue continue
except asyncio.CancelledError: except asyncio.CancelledError:
await self.disconnect()
return return
except Exception as e: except Exception as e:
if isinstance(e, ConnectionError): if isinstance(e, ConnectionError):
@ -467,15 +469,19 @@ class MTProtoSender:
__log__.info('Server replied with an unknown type {:08x}: {!r}' __log__.info('Server replied with an unknown type {:08x}: {!r}'
.format(e.invalid_constructor_id, e.remaining)) .format(e.invalid_constructor_id, e.remaining))
continue continue
except: except asyncio.CancelledError:
__log__.exception('Unhandled exception while unpacking') await self.disconnect()
return
except Exception as e:
__log__.exception('Unhandled exception while unpacking %s',e)
await asyncio.sleep(1) await asyncio.sleep(1)
else: else:
try: try:
await self._process_message(message) await self._process_message(message)
except asyncio.CancelledError: except asyncio.CancelledError:
await self.disconnect()
return return
except: except Exception as e:
__log__.exception('Unhandled exception while ' __log__.exception('Unhandled exception while '
'processing %s', message) 'processing %s', message)
await asyncio.sleep(1) await asyncio.sleep(1)