From 3c13043ca3865b44b335d57318ecf8462875ec83 Mon Sep 17 00:00:00 2001 From: nemunaire Date: Sun, 16 Jul 2017 21:15:10 +0200 Subject: [PATCH] run: recreate the sync_queue on run, it seems to have strange behaviour when created before the fork --- nemubot/bot.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/nemubot/bot.py b/nemubot/bot.py index ed46d48..b0d3915 100644 --- a/nemubot/bot.py +++ b/nemubot/bot.py @@ -151,6 +151,11 @@ class Bot(threading.Thread): def run(self): global sync_queue + # Rewrite the sync_queue, as the daemonization process tend to disturb it + old_sync_queue, sync_queue = sync_queue, JoinableQueue() + while not old_sync_queue.empty(): + sync_queue.put_nowait(old_sync_queue.get()) + self._poll.register(sync_queue._reader, select.POLLIN | select.POLLPRI) logger.info("Starting main loop") @@ -190,6 +195,8 @@ class Bot(threading.Thread): args = sync_queue.get() action = args.pop(0) + logger.debug("Executing sync_queue action %s%s", action, args) + if action == "sckt" and len(args) >= 2: try: if args[0] == "write":