summaryrefslogtreecommitdiff
path: root/sleekxmpp
diff options
context:
space:
mode:
authorBrian Beggs <macdiesel@gmail.com>2010-07-01 10:01:52 -0400
committerBrian Beggs <macdiesel@gmail.com>2010-07-01 10:01:52 -0400
commitf477ccf533a9b041e5f32b8b01e8381e05bcadf2 (patch)
tree187bf0f4516cc8cf7b644bf5d4990d305d73dcc1 /sleekxmpp
parentd62a30b0f8353640928d11cdfd76ea3c7a9b5cc3 (diff)
parent8bdfa770245ec02efbecf81bc598faa2b66a64f4 (diff)
downloadslixmpp-f477ccf533a9b041e5f32b8b01e8381e05bcadf2.tar.gz
slixmpp-f477ccf533a9b041e5f32b8b01e8381e05bcadf2.tar.bz2
slixmpp-f477ccf533a9b041e5f32b8b01e8381e05bcadf2.tar.xz
slixmpp-f477ccf533a9b041e5f32b8b01e8381e05bcadf2.zip
Merge remote branch 'tom/hacks'
Diffstat (limited to 'sleekxmpp')
-rw-r--r--sleekxmpp/basexmpp.py6
-rw-r--r--sleekxmpp/xmlstream/scheduler.py1
-rw-r--r--sleekxmpp/xmlstream/xmlstream.py39
3 files changed, 24 insertions, 22 deletions
diff --git a/sleekxmpp/basexmpp.py b/sleekxmpp/basexmpp.py
index 936b5d18..25eeedb0 100644
--- a/sleekxmpp/basexmpp.py
+++ b/sleekxmpp/basexmpp.py
@@ -109,9 +109,9 @@ class basexmpp(object):
if hasattr(self.plugin[plugin], 'xep'):
xep = "(XEP-%s) " % self.plugin[plugin].xep
logging.debug("Loaded Plugin %s%s" % (xep, self.plugin[plugin].description))
- except Exception, e:
- logging.error("Unable to load plugin: %s" %(plugin) )
- logging.exception(e)
+ except:
+ logging.exception("Unable to load plugin: %s", plugin )
+
def register_plugins(self):
"""Initiates all plugins in the plugins/__init__.__all__"""
diff --git a/sleekxmpp/xmlstream/scheduler.py b/sleekxmpp/xmlstream/scheduler.py
index 40aaf695..e4df02d1 100644
--- a/sleekxmpp/xmlstream/scheduler.py
+++ b/sleekxmpp/xmlstream/scheduler.py
@@ -41,6 +41,7 @@ class Scheduler(object):
def process(self, threaded=True):
if threaded:
self.thread = threading.Thread(name='shedulerprocess', target=self._process)
+ self.thread.daemon = True
self.thread.start()
else:
self._process()
diff --git a/sleekxmpp/xmlstream/xmlstream.py b/sleekxmpp/xmlstream/xmlstream.py
index a8bcac00..025a6cbf 100644
--- a/sleekxmpp/xmlstream/xmlstream.py
+++ b/sleekxmpp/xmlstream/xmlstream.py
@@ -59,7 +59,7 @@ class XMLStream(object):
self.ssl_support = ssl_support
self.escape_quotes = escape_quotes
self.state = statemachine.StateMachine(('disconnected','connecting',
- 'connected'))
+ 'connected'))
self.should_reconnect = True
self.setSocket(socket)
@@ -240,7 +240,7 @@ class XMLStream(object):
if self.should_reconnect:
self.disconnect(reconnect=True)
- logging.debug('Quitting Process thread')
+ logging.debug('Quitting Process thread')
def __readXML(self):
"Parses the incoming stream, adding to xmlin queue as it goes"
@@ -306,23 +306,24 @@ class XMLStream(object):
return True
def disconnect(self, reconnect=False):
- if not self.state.transition('connected','disconnected'):
- logging.warning("Already disconnected.")
- return
- logging.debug("Disconnecting...")
- self.sendPriorityRaw(self.stream_footer)
- time.sleep(5)
- #send end of stream
- #wait for end of stream back
- try:
-# self.socket.shutdown(socket.SHUT_RDWR)
- self.socket.close()
- except socket.error as (errno,strerror):
- logging.exception("Error while disconnecting. Socket Error #%s: %s" % (errno, strerror))
- try:
- self.filesocket.close()
- except socket.error as (errno,strerror):
- logging.exception("Error closing filesocket.")
+ with self.state.transition_ctx('connected','disconnected') as locked:
+ if not locked:
+ logging.warning("Already disconnected.")
+ return
+ logging.debug("Disconnecting...")
+ self.sendRaw(self.stream_footer)
+ time.sleep(5)
+ #send end of stream
+ #wait for end of stream back
+ try:
+# self.socket.shutdown(socket.SHUT_RDWR)
+ self.socket.close()
+ except socket.error as (errno,strerror):
+ logging.exception("Error while disconnecting. Socket Error #%s: %s" % (errno, strerror))
+ try:
+ self.filesocket.close()
+ except socket.error as (errno,strerror):
+ logging.exception("Error closing filesocket.")
if reconnect: self.connect()