Catch even more exceptions to stay connected or reconnect
This commit is contained in:
parent
7cfdc0f13b
commit
9c4f5e4372
1 changed files with 10 additions and 3 deletions
|
|
@ -73,7 +73,11 @@ class Connection:
|
||||||
self._clean_up_futures()
|
self._clean_up_futures()
|
||||||
self._clean_up_tasks()
|
self._clean_up_tasks()
|
||||||
|
|
||||||
await self._ws.close() # just to make sure
|
try:
|
||||||
|
await self._ws.close() # just to make sure
|
||||||
|
except:
|
||||||
|
pass # errors are not useful here
|
||||||
|
|
||||||
await self._pingtask # should stop now that the ws is closed
|
await self._pingtask # should stop now that the ws is closed
|
||||||
self._ws = None
|
self._ws = None
|
||||||
|
|
||||||
|
|
@ -92,7 +96,7 @@ class Connection:
|
||||||
logger.warning("Ping timed out.")
|
logger.warning("Ping timed out.")
|
||||||
await self._ws.close2()
|
await self._ws.close2()
|
||||||
break
|
break
|
||||||
except websockets.ConnectionClosed:
|
except (websockets.ConnectionClosed, ConnectionResetError):
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
await asyncio.sleep(self.ping_delay)
|
await asyncio.sleep(self.ping_delay)
|
||||||
|
|
@ -103,7 +107,10 @@ class Connection:
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if self._ws:
|
if self._ws:
|
||||||
await self._ws.close()
|
try:
|
||||||
|
await self._ws.close()
|
||||||
|
except:
|
||||||
|
pass # errors not useful here
|
||||||
|
|
||||||
if self._runtask:
|
if self._runtask:
|
||||||
await self._runtask
|
await self._runtask
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue