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":