Fix exception ignored warnings and invalid state #935

This commit is contained in:
Lonami Exo
2018-08-04 15:05:22 +02:00
parent d0c566bbdb
commit a688c8a4ce
2 changed files with 9 additions and 2 deletions

View File

@@ -151,7 +151,14 @@ class TcpClient:
loop=self._loop
)
for r in running:
r.cancel()
if not r.cancelled():
if r.done():
# Retrieve exception to avoid "not retrieved" errors
r.exception()
# Cancel the future despite its state
r.cancel()
if not self.is_connected:
raise self.SocketClosed()
if not done: