diff options
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> | 2014-08-16 22:37:29 +0200 |
---|---|---|
committer | Florent Le Coz <louiz@louiz.org> | 2014-09-01 02:47:08 +0200 |
commit | 6175cbcd99f917b08646d130770a132458056249 (patch) | |
tree | 7aa51df981039fdfec06c141feb5b61888a4e8f9 /slixmpp/xmlstream | |
parent | 476d76a53301f9da2ac7efa094e209b0607adfdc (diff) | |
download | slixmpp-6175cbcd99f917b08646d130770a132458056249.tar.gz slixmpp-6175cbcd99f917b08646d130770a132458056249.tar.bz2 slixmpp-6175cbcd99f917b08646d130770a132458056249.tar.xz slixmpp-6175cbcd99f917b08646d130770a132458056249.zip |
Reintroduce XMLStream.process, making it run the asyncio event loop.
Diffstat (limited to 'slixmpp/xmlstream')
-rw-r--r-- | slixmpp/xmlstream/xmlstream.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/slixmpp/xmlstream/xmlstream.py b/slixmpp/xmlstream/xmlstream.py index e3a8265a..ff5a3d26 100644 --- a/slixmpp/xmlstream/xmlstream.py +++ b/slixmpp/xmlstream/xmlstream.py @@ -302,6 +302,20 @@ class XMLStream(object): except OSError as e: self.event("connection_failed", e) + def process(self, timeout=None): + """Process all the available XMPP events (receiving or sending data on the + socket(s), calling various registered callbacks, calling expired + timers, handling signal events, etc). If timeout is None, this + function will run forever. If timeout is a number, this function + will return after the given time in seconds. + """ + loop = asyncio.get_event_loop() + if timeout is None: + loop.run_forever() + else: + future = asyncio.sleep(timeout) + loop.run_until_complete(future) + def init_parser(self): """init the XML parser. The parser must always be reset for each new connexion |