Close socket on strange errors and that's it

This commit is contained in:
Oleksii Shevchuk 2017-03-08 19:40:01 +02:00
parent 09b8ca0ac6
commit a41bc90c46
1 changed files with 5 additions and 2 deletions

View File

@ -184,8 +184,11 @@ class Connection(object):
def close(self, reason, mutual=True):
if mutual:
self.loop.queue_work(lambda: self.socket.shutdown(
lambda handle, error: self._report_close_remote(reason)))
try:
self.loop.queue_work(lambda: self.socket.shutdown(
lambda handle, error: self._report_close_remote(reason)))
except:
self.socket.close()
else:
self.socket.close()