From 49054070922958141808c48e9204cd5cdf6ca164 Mon Sep 17 00:00:00 2001 From: mathieui Date: Sat, 28 May 2016 14:46:39 +0200 Subject: Fix the ordering of stream features MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit since iq.send is non-blocking, some features handlers could end up being executed before others were set, leading to issues. Adding yield from where it’s necessary fixes that. --- slixmpp/features/feature_session/session.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'slixmpp/features/feature_session/session.py') diff --git a/slixmpp/features/feature_session/session.py b/slixmpp/features/feature_session/session.py index 0635455a..2f9548eb 100644 --- a/slixmpp/features/feature_session/session.py +++ b/slixmpp/features/feature_session/session.py @@ -6,6 +6,7 @@ See the file LICENSE for copying permission. """ +import asyncio import logging from slixmpp.stanza import Iq, StreamFeatures @@ -34,6 +35,7 @@ class FeatureSession(BasePlugin): register_stanza_plugin(Iq, stanza.Session) register_stanza_plugin(StreamFeatures, stanza.Session) + @asyncio.coroutine def _handle_start_session(self, features): """ Handle the start of the session. @@ -44,7 +46,7 @@ class FeatureSession(BasePlugin): iq = self.xmpp.Iq() iq['type'] = 'set' iq.enable('session') - iq.send(callback=self._on_start_session_response) + yield from iq.send(callback=self._on_start_session_response) def _on_start_session_response(self, response): self.xmpp.features.add('session') -- cgit v1.2.3