summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sleekxmpp/plugins/xep_0199.py6
-rw-r--r--sleekxmpp/xmlstream/xmlstream.py18
2 files changed, 14 insertions, 10 deletions
diff --git a/sleekxmpp/plugins/xep_0199.py b/sleekxmpp/plugins/xep_0199.py
index 3fc62f55..ccd284f8 100644
--- a/sleekxmpp/plugins/xep_0199.py
+++ b/sleekxmpp/plugins/xep_0199.py
@@ -16,14 +16,14 @@ class xep_0199(base.base_plugin):
def plugin_init(self):
self.description = "XMPP Ping"
self.xep = "0199"
- self.xmpp.add_handler("<iq type='get' xmlns='%s'><ping xmlns='http://www.xmpp.org/extensions/xep-0199.html#ns'/></iq>" % self.xmpp.default_ns, self.handler_ping, name='XMPP Ping')
+ self.xmpp.add_handler("<iq type='get' xmlns='%s'><ping xmlns='urn:xmpp:ping'/></iq>" % self.xmpp.default_ns, self.handler_ping, name='XMPP Ping')
self.running = False
#if self.config.get('keepalive', True):
#self.xmpp.add_event_handler('session_start', self.handler_pingserver, threaded=True)
def post_init(self):
base.base_plugin.post_init(self)
- self.xmpp.plugin['xep_0030'].add_feature('http://www.xmpp.org/extensions/xep-0199.html#ns')
+ self.xmpp.plugin['xep_0030'].add_feature('urn:xmpp:ping')
def handler_pingserver(self, xml):
if not self.running:
@@ -47,7 +47,7 @@ class xep_0199(base.base_plugin):
iq = self.xmpp.makeIq(id)
iq.attrib['type'] = 'get'
iq.attrib['to'] = jid
- ping = ET.Element('{http://www.xmpp.org/extensions/xep-0199.html#ns}ping')
+ ping = ET.Element('{urn:xmpp:ping}ping')
iq.append(ping)
startTime = time.clock()
#pingresult = self.xmpp.send(iq, self.xmpp.makeIq(id), timeout)
diff --git a/sleekxmpp/xmlstream/xmlstream.py b/sleekxmpp/xmlstream/xmlstream.py
index 546654dd..16412711 100644
--- a/sleekxmpp/xmlstream/xmlstream.py
+++ b/sleekxmpp/xmlstream/xmlstream.py
@@ -547,13 +547,22 @@ class XMLStream(object):
name -- The name of the event to trigger.
data -- Data that will be passed to each event handler.
Defaults to an empty dictionary.
- direct -- Runs the event directly if True.
+ direct -- Runs the event directly if True, skipping the
+ event queue. All event handlers will run in the
+ same thread.
"""
for handler in self.__event_handlers.get(name, []):
if direct:
- handler[0](copy.copy(data))
+ try:
+ handler[0](copy.copy(data))
+ except Exception as e:
+ error_msg = 'Error processing event handler: %s'
+ logging.exception(error_msg % str(handler[0]))
+ if hasattr(data, 'exception'):
+ data.exception(e)
else:
self.event_queue.put(('event', handler, copy.copy(data)))
+
if handler[2]:
# If the handler is disposable, we will go ahead and
# remove it now instead of waiting for it to be
@@ -819,11 +828,6 @@ class XMLStream(object):
"""
try:
func(*args)
- except Exception as e:
- error_msg = 'Error processing event handler: %s'
- logging.exception(error_msg % str(func))
- if hasattr(args[0], 'exception'):
- args[0].exception(e)
def _event_runner(self):
"""