From 2f3b0743800342b8b79f74ec5ba52686a90cda8d Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Fri, 2 Oct 2026 15:23:49 -0400 Subject: [PATCH] Cleanly shut down the drawing thread --- confluent_client/bin/nodeconsole | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/confluent_client/bin/nodeconsole b/confluent_client/bin/nodeconsole index 26d3e38f..74b9b988 100755 --- a/confluent_client/bin/nodeconsole +++ b/confluent_client/bin/nodeconsole @@ -16,6 +16,7 @@ # limitations under the License. +import atexit import asyncio import base64 import optparse @@ -1130,7 +1131,10 @@ def draw_node(node, imgdata, errorstr, firstnodename, cwidth, cheight): def _draw_worker(): while True: - node, imgdata, errorstr, firstnodename, cwidth, cheight = draw_queue.get() + item = draw_queue.get() + if item is None: + break + node, imgdata, errorstr, firstnodename, cwidth, cheight = item with draw_lock: _draw_node(node, imgdata, errorstr, firstnodename, cwidth, cheight) @@ -1161,6 +1165,18 @@ def _draw_node(node, imgdata, errorstr, firstnodename, cwidth, cheight): draw_thread = threading.Thread(target=_draw_worker, daemon=True) draw_thread.start() +def close_draw_thread(): + global draw_thread + if not draw_thread: + return + mythread = draw_thread + draw_thread = None + if mythread.is_alive(): + draw_queue.put(None) + mythread.join(15) + +atexit.register(close_draw_thread) + if options.screenshot or options.video: if not sys.stdout.isatty(): sys.stderr.write(