summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--slixmpp/xmlstream/xmlstream.py51
1 files changed, 27 insertions, 24 deletions
diff --git a/slixmpp/xmlstream/xmlstream.py b/slixmpp/xmlstream/xmlstream.py
index 4403178c..200701ea 100644
--- a/slixmpp/xmlstream/xmlstream.py
+++ b/slixmpp/xmlstream/xmlstream.py
@@ -902,30 +902,33 @@ class XMLStream(asyncio.BaseProtocol):
"""
while True:
(data, use_filters) = await self.waiting_queue.get()
- if isinstance(data, ElementBase):
- if use_filters:
- for filter in self.__filters['out']:
- if iscoroutinefunction(filter):
- data = await filter(data)
- else:
- data = filter(data)
- if data is None:
- return
-
- if isinstance(data, ElementBase):
- if use_filters:
- for filter in self.__filters['out_sync']:
- if iscoroutinefunction(filter):
- data = await filter(data)
- else:
- data = filter(data)
- if data is None:
- return
- str_data = tostring(data.xml, xmlns=self.default_ns,
- stream=self, top_level=True)
- self.send_raw(str_data)
- else:
- self.send_raw(data)
+ try:
+ if isinstance(data, ElementBase):
+ if use_filters:
+ for filter in self.__filters['out']:
+ if iscoroutinefunction(filter):
+ data = await filter(data)
+ else:
+ data = filter(data)
+ if data is None:
+ return
+
+ if isinstance(data, ElementBase):
+ if use_filters:
+ for filter in self.__filters['out_sync']:
+ if iscoroutinefunction(filter):
+ data = await filter(data)
+ else:
+ data = filter(data)
+ if data is None:
+ return
+ str_data = tostring(data.xml, xmlns=self.default_ns,
+ stream=self, top_level=True)
+ self.send_raw(str_data)
+ else:
+ self.send_raw(data)
+ except:
+ log.error('Could not send stanza %s', data, exc_info=True)
self.waiting_queue.task_done()
def send(self, data, use_filters=True):