2
0
mirror of https://github.com/xcat2/confluent.git synced 2026-08-03 16:07:00 +00:00

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.
This commit is contained in:
Markus Hilger
2026-07-27 01:54:24 +02:00
parent 15670f0ab1
commit 53f1d4a7c2
2 changed files with 2 additions and 3 deletions
+1 -1
View File
@@ -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):
+1 -2
View File
@@ -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'})])