From 43cb81ff03c574c45da325c9f8149b8b3282f070 Mon Sep 17 00:00:00 2001 From: Lars-Dominik Braun Date: Sat, 2 Feb 2019 10:40:22 +0100 Subject: irc: Retry if reconnect fails --- crocoite/irc.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/crocoite/irc.py b/crocoite/irc.py index 5351a85..855d0b0 100644 --- a/crocoite/irc.py +++ b/crocoite/irc.py @@ -334,10 +334,14 @@ class ArgparseBot (bottom.Client): async def onDisconnect (self, **kwargs): """ Auto-reconnect """ self.logger.info ('disconnect', uuid='4c74b2c8-2403-4921-879d-2279ad85db72') - if not self._quit.armed: - await asyncio.sleep (10, loop=self.loop) - self.logger.info ('reconnect', uuid='c53555cb-e1a4-4b69-b1c9-3320269c19d7') - await self.connect () + while True: + if not self._quit.armed: + await asyncio.sleep (10, loop=self.loop) + self.logger.info ('reconnect', uuid='c53555cb-e1a4-4b69-b1c9-3320269c19d7') + try: + await self.connect () + finally: + break def voice (func): """ Calling user must have voice or ops """ -- cgit v1.2.3