* fixed many stanza bugs

* added stanza unhandled (unhandled iqs now reply with feature-not-implemented)
* added stanza exceptions (stanzas may now reply with exceptions when their handler raises an exception)
This commit is contained in:
Nathan Fritz
2009-12-17 01:54:22 +00:00
parent 6897a0b57c
commit 07018c0afa
13 changed files with 262 additions and 125 deletions

View File

@@ -262,6 +262,8 @@ class XMLStream(object):
handler.prerun(stanza)
self.eventqueue.put(('stanza', handler, stanza))
if handler.checkDelete(): self.__handlers.pop(self.__handlers.index(handler))
else:
stanza.unhandled()
#loop through handlers and test match
#spawn threads as necessary, call handlers, sending Stanza
@@ -274,10 +276,18 @@ class XMLStream(object):
except queue.Empty:
event = None
if event is not None:
etype, handler, stanza = event
etype, handler, *args = event
if etype == 'stanza':
handler.run(stanza)
if etype == 'quit':
try:
handler.run(args[0])
except:
args[0].exception(traceback.format_exc())
elif etype == 'sched':
try:
handler.run(*args)
except:
logging.error(traceback.format_exc())
elif etype == 'quit':
logging.debug("Quitting eventRunner thread")
return False