Merge branch 'disconnect-event-after-cleanup' into 'master'
XMLStream: Only fire "disconnected" after removal of related objects See merge request poezio/slixmpp!99
This commit is contained in:
commit
b784b68bcd
@ -458,9 +458,6 @@ class XMLStream(asyncio.BaseProtocol):
|
|||||||
closure of the TCP connection
|
closure of the TCP connection
|
||||||
"""
|
"""
|
||||||
log.info("connection_lost: %s", (exception,))
|
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
|
# All these objects are associated with one TCP connection. Since
|
||||||
# we are not connected anymore, destroy them
|
# we are not connected anymore, destroy them
|
||||||
self.parser = None
|
self.parser = None
|
||||||
@ -468,6 +465,10 @@ class XMLStream(asyncio.BaseProtocol):
|
|||||||
self.socket = None
|
self.socket = None
|
||||||
if self._run_filters:
|
if self._run_filters:
|
||||||
self._run_filters.cancel()
|
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):
|
def cancel_connection_attempt(self):
|
||||||
"""
|
"""
|
||||||
@ -482,7 +483,6 @@ class XMLStream(asyncio.BaseProtocol):
|
|||||||
if self._run_filters:
|
if self._run_filters:
|
||||||
self._run_filters.cancel()
|
self._run_filters.cancel()
|
||||||
|
|
||||||
|
|
||||||
def disconnect(self, wait: float = 2.0, reason: Optional[str] = None, ignore_send_queue: bool = False) -> None:
|
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
|
"""Close the XML stream and wait for an acknowldgement from the server for
|
||||||
at most `wait` seconds. After the given number of seconds has
|
at most `wait` seconds. After the given number of seconds has
|
||||||
|
Loading…
Reference in New Issue
Block a user