From 8e43db2533ca76338dff794cf316440e1b1a4236 Mon Sep 17 00:00:00 2001 From: Sophie Tauchert Date: Sat, 14 Jan 2023 14:24:35 +0100 Subject: [PATCH] Don't resubscribe immediately after connection loss --- ntfy/bot.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ntfy/bot.py b/ntfy/bot.py index 38b9719..131af7f 100644 --- a/ntfy/bot.py +++ b/ntfy/bot.py @@ -128,7 +128,10 @@ class NtfyBot(Plugin): exc = task.exception() self.log.exception( "Subscription task errored, resubscribing", exc_info=exc) - self.subscribe_to_topic(topic) + self.tasks[topic.id] = self.loop.create_task( + asyncio.sleep(10.0)) + self.tasks[topic.id].add_done_callback( + lambda _: self.subscribe_to_topic(topic)) self.log.info("Subscribing to %s/%s", topic.server, topic.topic) url = "%s/%s/json" % (topic.server, topic.topic)