From 73c6674306599000281064b599545aaaa24a5448 Mon Sep 17 00:00:00 2001 From: Timofey Titovets Date: Fri, 25 Jul 2025 19:13:20 +0200 Subject: [PATCH] queuelogger: set thread name Python 2.7 does not allow loading the cffi lib inside the thread, but function calls are allowed Signed-off-by: Timofey Titovets --- klippy/queuelogger.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/klippy/queuelogger.py b/klippy/queuelogger.py index c6447f8e..7fa93ace 100644 --- a/klippy/queuelogger.py +++ b/klippy/queuelogger.py @@ -4,6 +4,7 @@ # # This file may be distributed under the terms of the GNU GPLv3 license. import logging, logging.handlers, threading, queue, time +import chelper # Class to forward all messages through a queue to a background thread class QueueHandler(logging.Handler): @@ -25,11 +26,15 @@ class QueueListener(logging.handlers.TimedRotatingFileHandler): def __init__(self, filename): logging.handlers.TimedRotatingFileHandler.__init__( self, filename, when='midnight', backupCount=5) + _, ffi_lib = chelper.get_ffi() + self._set_thread_name = ffi_lib.set_thread_name self.bg_queue = queue.Queue() self.bg_thread = threading.Thread(target=self._bg_thread) self.bg_thread.start() self.rollover_info = {} def _bg_thread(self): + name_short = "queuelogger"[:15] + self._set_thread_name(name_short.encode('utf-8')) while 1: record = self.bg_queue.get(True) if record is None: