summaryrefslogtreecommitdiff
path: root/slixmpp/xmlstream/xmlstream.py
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2021-01-25 10:00:40 +0100
committermathieui <mathieui@mathieui.net>2021-01-29 15:33:44 +0100
commitf15311bda8e5d1c227174771a30cde7013b0658f (patch)
treee9b06c7dcda293ccd128fd0ef16294bcb4203a9d /slixmpp/xmlstream/xmlstream.py
parentb2dfb4c1f3ac2d7d034942bac41b7d026bc90699 (diff)
downloadslixmpp-f15311bda8e5d1c227174771a30cde7013b0658f.tar.gz
slixmpp-f15311bda8e5d1c227174771a30cde7013b0658f.tar.bz2
slixmpp-f15311bda8e5d1c227174771a30cde7013b0658f.tar.xz
slixmpp-f15311bda8e5d1c227174771a30cde7013b0658f.zip
xmlstream: Make the reconnect handler a coroutine
Diffstat (limited to 'slixmpp/xmlstream/xmlstream.py')
-rw-r--r--slixmpp/xmlstream/xmlstream.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/slixmpp/xmlstream/xmlstream.py b/slixmpp/xmlstream/xmlstream.py
index c84b40e1..2cc5fe17 100644
--- a/slixmpp/xmlstream/xmlstream.py
+++ b/slixmpp/xmlstream/xmlstream.py
@@ -585,7 +585,11 @@ class XMLStream(asyncio.BaseProtocol):
when the server acknowledgement is received), call connect()
"""
log.debug("reconnecting...")
- self.add_event_handler('disconnected', lambda event: self.connect(), disposable=True)
+ async def handler(event):
+ # We yield here to allow synchronous handlers to work first
+ await asyncio.sleep(0, loop=self.loop)
+ self.connect()
+ self.add_event_handler('disconnected', handler, disposable=True)
self.disconnect(wait, reason)
def configure_socket(self):