Merge pull request #183 from andvikt/master

Added cancel pending tasks coro
pull/8/head
Nicolas 2019-07-28 12:28:26 +02:00 zatwierdzone przez GitHub
commit 3f8c994f58
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
1 zmienionych plików z 14 dodań i 1 usunięć

Wyświetl plik

@ -164,7 +164,7 @@ class MQTTClient:
This method is a *coroutine*.
"""
yield from self.cancel_tasks()
if self.session.transitions.is_connected():
if not self._disconnect_task.done():
self._disconnect_task.cancel()
@ -175,6 +175,19 @@ class MQTTClient:
else:
self.logger.warning("Client session is not currently connected, ignoring call")
@asyncio.coroutine
def cancel_tasks(self):
"""
Before disconnection need to cancel all pending tasks
:return:
"""
try:
while True:
task = self.client_tasks.pop()
task.cancel()
except IndexError as err:
pass
@asyncio.coroutine
def reconnect(self, cleansession=None):
"""