Don't spin up further scheduling threads on reconnect.
authorCMDR furrycat <elite@furrycat.net>
Thu, 6 Oct 2016 10:46:35 +0000 (11:46 +0100)
committerCMDR furrycat <elite@furrycat.net>
Thu, 6 Oct 2016 10:46:35 +0000 (11:46 +0100)
bot.py

diff --git a/bot.py b/bot.py
index b33d185..8260516 100755 (executable)
--- a/bot.py
+++ b/bot.py
@@ -69,6 +69,7 @@ log.setLevel(logging.DEBUG if debug else logging.INFO)
 idletime = multiprocessing.Value('i', 900)
 rsstime = multiprocessing.Value('i', 600)
 playing = multiprocessing.Value('b', False)
+threads_ready = multiprocessing.Value('b', False)
 
 bots = {
   # catbot
@@ -1169,9 +1170,11 @@ def on_ready():
     log.debug('Maybe unassigning {}'.format(member.name))
     yield from set_unassigned(member)
   log.info('RSS feeds: {}'.format([feed['description'] for feed in feeds if 'description' in feed]))
-  asyncio.async(do_feeds())
-  asyncio.async(do_announcements())
-  asyncio.async(maybe_sleep())
+  if not threads_ready.value:
+    asyncio.async(do_feeds())
+    asyncio.async(do_announcements())
+    asyncio.async(maybe_sleep())
+    threads_ready.value = True
 
 def mentioned_in(message, explicit = True):
   if message.channel.is_private: