From 0ff3f9754bdbab62e3e456dbfad0726012b0787f Mon Sep 17 00:00:00 2001 From: Alexei Sorokin Date: Mon, 19 Jun 2017 19:47:42 +0300 Subject: [PATCH] Fix a reconnecting regression --- hybridbot.py | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/hybridbot.py b/hybridbot.py index 3e06ca5..e6b3bdf 100755 --- a/hybridbot.py +++ b/hybridbot.py @@ -135,15 +135,22 @@ class XMPPBot: def connect(self): self.client.connect() - @asyncio.coroutine - def join_muc_loop(self): - muc_plugin = self.client.plugin['xep_0045'] - while not self.muc_is_joined: - muc_plugin.join_muc(self.muc, self.nick) - yield from asyncio.sleep(self.timeout) - def join_muc(self): - asyncio.async(self.join_muc_loop()) + muc_plugin = self.client.plugin['xep_0045'] + @asyncio.coroutine + def loop_cycle(): + if self._join_muc_block > 0: + return + self._join_muc_block += 1 + + while not self.muc_is_joined: + muc_plugin.join_muc(self.muc, self.nick) + yield from asyncio.sleep(self.timeout) + + self._join_muc_block -= 1 + + asyncio.async(loop_cycle()) + _join_muc_block = 0 def on_failed_all_auth(event): # print('could not connect!', file=sys.stderr)