diff options
author | Florent Le Coz <louiz@louiz.org> | 2015-01-03 05:55:17 +0100 |
---|---|---|
committer | Florent Le Coz <louiz@louiz.org> | 2015-01-03 06:08:03 +0100 |
commit | 47fbd4cead2e881b0250dd5f978caf64c6a5952c (patch) | |
tree | ce556dce5c575c3a1d7067ba6196ba0b68d72265 /slixmpp/xmlstream/xmlstream.py | |
parent | 1b9b4199e8ecfdc379a34b74dd9b3b197365d74a (diff) | |
download | slixmpp-47fbd4cead2e881b0250dd5f978caf64c6a5952c.tar.gz slixmpp-47fbd4cead2e881b0250dd5f978caf64c6a5952c.tar.bz2 slixmpp-47fbd4cead2e881b0250dd5f978caf64c6a5952c.tar.xz slixmpp-47fbd4cead2e881b0250dd5f978caf64c6a5952c.zip |
Delay the handling of stanza for when the process is not busy
We use some dirty monkey-patching to add a idle_call() function to the
asyncio module. We then use that method to handle each received stanza only
when the event loop is not busy with some other IO (mainly, the standard
input)
Diffstat (limited to 'slixmpp/xmlstream/xmlstream.py')
-rw-r--r-- | slixmpp/xmlstream/xmlstream.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/slixmpp/xmlstream/xmlstream.py b/slixmpp/xmlstream/xmlstream.py index 187bfbc5..f1abfca6 100644 --- a/slixmpp/xmlstream/xmlstream.py +++ b/slixmpp/xmlstream/xmlstream.py @@ -12,7 +12,6 @@ :license: MIT, see LICENSE for more details """ -import asyncio import functools import copy import logging @@ -23,6 +22,7 @@ import uuid import xml.etree.ElementTree +from slixmpp.xmlstream.asyncio import asyncio from slixmpp.xmlstream import tostring from slixmpp.xmlstream.stanzabase import StanzaBase, ElementBase from slixmpp.xmlstream.resolver import resolve, default_resolver @@ -377,7 +377,8 @@ class XMLStream(object): elif self.xml_depth == 1: # A stanza is an XML element that is a direct child of # the root element, hence the check of depth == 1 - self.__spawn_event(xml) + asyncio.get_event_loop().\ + idle_call(functools.partial(self.__spawn_event, xml)) if self.xml_root is not None: # Keep the root element empty of children to # save on memory use. |