summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2021-01-19 21:12:52 +0100
committermathieui <mathieui@mathieui.net>2021-01-19 21:12:52 +0100
commitb784b68bcdface791f2a6e0e0a5482096b03ee06 (patch)
tree8b5b3825d69614fae2c1801c39d5a3595d5fbef2
parent2631b25e3e58311b9d101b4217f878fa375db974 (diff)
parentf38c61a6b9ee4730577374ab02fb66d258b9a831 (diff)
downloadslixmpp-b784b68bcdface791f2a6e0e0a5482096b03ee06.tar.gz
slixmpp-b784b68bcdface791f2a6e0e0a5482096b03ee06.tar.bz2
slixmpp-b784b68bcdface791f2a6e0e0a5482096b03ee06.tar.xz
slixmpp-b784b68bcdface791f2a6e0e0a5482096b03ee06.zip
Merge branch 'disconnect-event-after-cleanup' into 'master'
XMLStream: Only fire "disconnected" after removal of related objects See merge request poezio/slixmpp!99
-rw-r--r--slixmpp/xmlstream/xmlstream.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/slixmpp/xmlstream/xmlstream.py b/slixmpp/xmlstream/xmlstream.py
index 14020e1c..dc2af77e 100644
--- a/slixmpp/xmlstream/xmlstream.py
+++ b/slixmpp/xmlstream/xmlstream.py
@@ -458,9 +458,6 @@ class XMLStream(asyncio.BaseProtocol):
closure of the TCP connection
"""
log.info("connection_lost: %s", (exception,))
- self.event("disconnected", self.disconnect_reason or exception and exception.strerror)
- if self.end_session_on_disconnect:
- self.event('session_end')
# All these objects are associated with one TCP connection. Since
# we are not connected anymore, destroy them
self.parser = None
@@ -468,6 +465,10 @@ class XMLStream(asyncio.BaseProtocol):
self.socket = None
if self._run_filters:
self._run_filters.cancel()
+ # Fire the events after cleanup
+ if self.end_session_on_disconnect:
+ self.event('session_end')
+ self.event("disconnected", self.disconnect_reason or exception and exception.strerror)
def cancel_connection_attempt(self):
"""
@@ -481,7 +482,6 @@ class XMLStream(asyncio.BaseProtocol):
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