From c3b1c7534cda14eece6ea493d863a4edb3eebdcc 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 2407496..6ab6c34 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":