summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2019-08-23 21:53:21 +0200
committermathieui <mathieui@mathieui.net>2019-12-27 15:27:29 +0100
commita0f5cb6e0921631763e29e27957286dcd8e38442 (patch)
treea330da149240104417cbcf542d30a096c65e7fcc
parent110bbf8afc17244ae4ecc9a0cb7ca799bb121834 (diff)
downloadslixmpp-a0f5cb6e0921631763e29e27957286dcd8e38442.tar.gz
slixmpp-a0f5cb6e0921631763e29e27957286dcd8e38442.tar.bz2
slixmpp-a0f5cb6e0921631763e29e27957286dcd8e38442.tar.xz
slixmpp-a0f5cb6e0921631763e29e27957286dcd8e38442.zip
Put the queue exception at toplevel
-rw-r--r--slixmpp/xmlstream/xmlstream.py16
1 files changed, 10 insertions, 6 deletions
diff --git a/slixmpp/xmlstream/xmlstream.py b/slixmpp/xmlstream/xmlstream.py
index 83a43dbc..dbf515ca 100644
--- a/slixmpp/xmlstream/xmlstream.py
+++ b/slixmpp/xmlstream/xmlstream.py
@@ -34,6 +34,10 @@ from slixmpp.xmlstream.resolver import resolve, default_resolver
RESPONSE_TIMEOUT = 30
log = logging.getLogger(__name__)
+class ContinueQueue(Exception):
+ """
+ Exception raised in the send queue to "continue" from within an inner loop
+ """
class NotConnectedError(Exception):
"""
@@ -896,10 +900,11 @@ class XMLStream(asyncio.BaseProtocol):
"""
return xml
- async def _continue_slow_send(self,
+ async def _continue_slow_send(
+ self,
task: asyncio.Task,
already_used: Set[Callable[[ElementBase], Optional[StanzaBase]]]
- ) -> None:
+ ) -> None:
"""
Used when an item in the send queue has taken too long to process.
@@ -934,7 +939,6 @@ class XMLStream(asyncio.BaseProtocol):
"""
Background loop that processes stanzas to send.
"""
- class ContinueQueue(Exception): pass
while True:
(data, use_filters) = await self.waiting_queue.get()
try:
@@ -961,21 +965,21 @@ class XMLStream(asyncio.BaseProtocol):
else:
data = filter(data)
if data is None:
- raise Exception('Empty stanza')
+ raise ContinueQueue('Empty stanza')
if isinstance(data, ElementBase):
if use_filters:
for filter in self.__filters['out_sync']:
data = filter(data)
if data is None:
- raise Exception('Empty stanza')
+ raise ContinueQueue('Empty stanza')
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 ContinueQueue as exc:
- log.info('Stanza in send queue not sent: %s', exc)
+ log.debug('Stanza in send queue not sent: %s', exc)
except Exception:
log.error('Exception raised in send queue:', exc_info=True)
self.waiting_queue.task_done()