Don't resubscribe immediately after connection loss

This commit is contained in:
Sophie Tauchert 2023-01-14 14:24:35 +01:00
parent c83f3cfcdf
commit 8e43db2533
No known key found for this signature in database
GPG Key ID: 52701DE5F5F51125
1 changed files with 4 additions and 1 deletions

View File

@ -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)