summaryrefslogtreecommitdiff
path: root/sleekxmpp/xmlstream/xmlstream.py
diff options
context:
space:
mode:
authorNathan Fritz <nathan@andyet.net>2010-10-20 17:30:12 -0700
committerNathan Fritz <nathan@andyet.net>2010-10-20 17:30:12 -0700
commit11264fe0a8d1224b9a185fc0439359477ef9c3cc (patch)
tree7c3f5ffb7cd111eedc2dce5e92c44572619db504 /sleekxmpp/xmlstream/xmlstream.py
parent11a6e6d2e02c8da7b3b94c8ad7cafc6de1323e61 (diff)
downloadslixmpp-11264fe0a8d1224b9a185fc0439359477ef9c3cc.tar.gz
slixmpp-11264fe0a8d1224b9a185fc0439359477ef9c3cc.tar.bz2
slixmpp-11264fe0a8d1224b9a185fc0439359477ef9c3cc.tar.xz
slixmpp-11264fe0a8d1224b9a185fc0439359477ef9c3cc.zip
capture SIGHUP and SIGTERM (windows) and disconnect; also testall no longer loads string26 with python3
Diffstat (limited to 'sleekxmpp/xmlstream/xmlstream.py')
-rw-r--r--sleekxmpp/xmlstream/xmlstream.py14
1 files changed, 13 insertions, 1 deletions
diff --git a/sleekxmpp/xmlstream/xmlstream.py b/sleekxmpp/xmlstream/xmlstream.py
index 3459f507..41ee8329 100644
--- a/sleekxmpp/xmlstream/xmlstream.py
+++ b/sleekxmpp/xmlstream/xmlstream.py
@@ -16,6 +16,7 @@ import sys
import threading
import time
import types
+import signal
try:
import queue
except ImportError:
@@ -195,6 +196,17 @@ class XMLStream(object):
self.auto_reconnect = True
self.is_client = False
+ signal.signal(signal.SIGHUP, self._handle_kill)
+ signal.signal(signal.SIGTERM, self._handle_kill) # used in Windows
+
+ def _handle_kill(self, signum, frame):
+ """
+ Capture kill event and disconnect cleanly after first
+ spawning the "killed" event.
+ """
+ self.event("killed", direct=True)
+ self.disconnect()
+
def new_id(self):
"""
Generate and return a new stream ID in hexadecimal form.
@@ -710,7 +722,7 @@ class XMLStream(object):
if depth == 0:
# The stream's root element has closed,
# terminating the stream.
- logging.debug("Ending read XML loop")
+ logging.debug("End of stream recieved")
self.stream_end_event.set()
return False
elif depth == 1: