summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLance Stout <lancestout@gmail.com>2012-08-10 14:12:05 -0700
committerLance Stout <lancestout@gmail.com>2012-08-10 14:12:05 -0700
commitf7a710e55bf433a378dee4bd05f6ceb59f2e9e2d (patch)
tree8cc0780116a85c77b62549621a20ff5f1501c4a4
parent814a50e36feb73ced9152680560261addf3ff0ea (diff)
downloadslixmpp-f7a710e55bf433a378dee4bd05f6ceb59f2e9e2d.tar.gz
slixmpp-f7a710e55bf433a378dee4bd05f6ceb59f2e9e2d.tar.bz2
slixmpp-f7a710e55bf433a378dee4bd05f6ceb59f2e9e2d.tar.xz
slixmpp-f7a710e55bf433a378dee4bd05f6ceb59f2e9e2d.zip
Add abort() method to kill the session and stop all processing without properly closing the stream.
-rw-r--r--sleekxmpp/xmlstream/xmlstream.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/sleekxmpp/xmlstream/xmlstream.py b/sleekxmpp/xmlstream/xmlstream.py
index 8f8e94fd..f56c360e 100644
--- a/sleekxmpp/xmlstream/xmlstream.py
+++ b/sleekxmpp/xmlstream/xmlstream.py
@@ -726,6 +726,20 @@ class XMLStream(object):
self.event("disconnected", direct=True)
return True
+ def abort(self):
+ self.session_started_event.clear()
+ self.stop.set()
+ if self._disconnect_wait_for_threads:
+ self._wait_for_threads()
+ try:
+ self.socket.shutdown(Socket.SHUT_RDWR)
+ self.socket.close()
+ self.filesocket.close()
+ except Socket.error:
+ pass
+ self.state.transition_any(['connected', 'disconnected'], 'disconnected', func=lambda: True)
+ self.event("killed", direct=True)
+
def reconnect(self, reattempt=True, wait=False, send_close=True):
"""Reset the stream's state and reconnect to the server."""
log.debug("reconnecting...")