From 53f1d4a7c27464ac9af3697e8548804860daf2bb Mon Sep 17 00:00:00 2001 From: Markus Hilger Date: Mon, 27 Jul 2026 01:54:24 +0200 Subject: [PATCH] Do not block the event loop with time.sleep in the async clients nodediscover's rescan poll and nodeconsole's screenshot refresh both slept with time.sleep inside a coroutine. In nodeconsole --video that stops the input handler and the VNC streaming tasks for the whole interval. --- confluent_client/bin/nodeconsole | 2 +- confluent_client/bin/nodediscover | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/confluent_client/bin/nodeconsole b/confluent_client/bin/nodeconsole index 29e9f204..fe6decc9 100755 --- a/confluent_client/bin/nodeconsole +++ b/confluent_client/bin/nodeconsole @@ -910,7 +910,7 @@ async def do_screenshot(): dorefresh = False else: dorefresh = True - time.sleep(options.interval) + await asyncio.sleep(options.interval) sys.exit(0) async def grab_vncs(urlbynode): diff --git a/confluent_client/bin/nodediscover b/confluent_client/bin/nodediscover index 36fc6b95..6838b911 100755 --- a/confluent_client/bin/nodediscover +++ b/confluent_client/bin/nodediscover @@ -20,7 +20,6 @@ import csv import optparse import os import sys -import time path = os.path.dirname(os.path.realpath(__file__)) path = os.path.realpath(os.path.join(path, '..', 'lib', 'python')) @@ -364,7 +363,7 @@ async def assign_discovery(options, session, needid=True): async def blocking_scan(session): list([x async for x in session.update('/discovery/rescan', {'rescan': 'start'})]) while(list([x async for x in session.read('/discovery/rescan')])[0].get('scanning', False)): - time.sleep(0.5) + await asyncio.sleep(0.5) list([x async for x in session.update('/networking/macs/rescan', {'rescan': 'start'})])