diff options
author | Maxime Buquet <pep@bouah.net> | 2020-10-01 17:15:06 +0200 |
---|---|---|
committer | Maxime Buquet <pep@bouah.net> | 2020-10-01 17:15:06 +0200 |
commit | 985505297c259656d101a133d1b007224fb9fdb9 (patch) | |
tree | df3fad0d9ce2037a75f46b73d1ae8fd2ed4fea3d | |
parent | 0b38eeaa4a946af1c7b19ff57ae558c5a7b3dfce (diff) | |
parent | 145bb7a36ed72369a8a4a2f6e475a2fd484da565 (diff) | |
download | slixmpp-985505297c259656d101a133d1b007224fb9fdb9.tar.gz slixmpp-985505297c259656d101a133d1b007224fb9fdb9.tar.bz2 slixmpp-985505297c259656d101a133d1b007224fb9fdb9.tar.xz slixmpp-985505297c259656d101a133d1b007224fb9fdb9.zip |
Merge branch 'master' into 'master'
Cancel run_filters task upon disconnect
See merge request poezio/slixmpp!57
-rw-r--r-- | slixmpp/xmlstream/xmlstream.py | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/slixmpp/xmlstream/xmlstream.py b/slixmpp/xmlstream/xmlstream.py index 3aac8c8e..af494903 100644 --- a/slixmpp/xmlstream/xmlstream.py +++ b/slixmpp/xmlstream/xmlstream.py @@ -228,6 +228,8 @@ class XMLStream(asyncio.BaseProtocol): self.add_event_handler('disconnected', self._remove_schedules) self.add_event_handler('session_start', self._start_keepalive) + + self._run_filters = None @property def loop(self): @@ -271,10 +273,12 @@ class XMLStream(asyncio.BaseProtocol): localhost """ - asyncio.ensure_future( - self.run_filters(), - loop=self.loop, - ) + if self._run_filters is None: + self._run_filters = asyncio.ensure_future( + self.run_filters(), + loop=self.loop, + ) + self.disconnect_reason = None self.cancel_connection_attempt() self.connect_loop_wait = 0 @@ -463,6 +467,8 @@ class XMLStream(asyncio.BaseProtocol): self.parser = None self.transport = None self.socket = None + if self._run_filters: + self._run_filters.cancel() def cancel_connection_attempt(self): """ @@ -474,6 +480,9 @@ class XMLStream(asyncio.BaseProtocol): if self._current_connection_attempt: self._current_connection_attempt.cancel() self._current_connection_attempt = None + if self._run_filters: + self._run_filters.cancel() + def disconnect(self, wait: float = 2.0, reason: Optional[str] = None, ignore_send_queue: bool = False) -> None: """Close the XML stream and wait for an acknowldgement from the server for |