From b96d4b4103ee2ed7edb5035f8a1145147d35fa79 Mon Sep 17 00:00:00 2001 From: Markus Hilger Date: Mon, 10 Aug 2026 04:39:28 +0200 Subject: [PATCH] Give the aiohmi command line utilities an event loop Console.main_loop drives Session.wait_for_rsp, which is a coroutine, so it spun without ever waiting for a packet. It is a coroutine now, and pyghmicons runs its main under asyncio.run. pyghmiutil had the same shape around Command.eventloop. --- confluent_server/aiohmi/cmd/pyghmicons.py | 7 ++++--- confluent_server/aiohmi/cmd/pyghmiutil.py | 7 ++++--- confluent_server/aiohmi/ipmi/console.py | 4 ++-- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/confluent_server/aiohmi/cmd/pyghmicons.py b/confluent_server/aiohmi/cmd/pyghmicons.py index 590ff3b5..0cb0d6f5 100755 --- a/confluent_server/aiohmi/cmd/pyghmicons.py +++ b/confluent_server/aiohmi/cmd/pyghmicons.py @@ -14,6 +14,7 @@ """ A simple little script to exemplify/test ipmi.console module """ +import asyncio import fcntl import os import select @@ -50,7 +51,7 @@ def _print(data): raise Exception(data) -def main(): +async def main(): tcattr = termios.tcgetattr(sys.stdin) newtcattr = tcattr # TODO(jbjohnso): add our exit handler @@ -75,7 +76,7 @@ def main(): inputthread = threading.Thread(target=_doinput, args=(sol,)) inputthread.daemon = True inputthread.start() - sol.main_loop() + await sol.main_loop() except Exception: currfl = fcntl.fcntl(sys.stdin.fileno(), fcntl.F_GETFL) @@ -85,4 +86,4 @@ def main(): if __name__ == '__main__': - sys.exit(main()) + sys.exit(asyncio.run(main())) diff --git a/confluent_server/aiohmi/cmd/pyghmiutil.py b/confluent_server/aiohmi/cmd/pyghmiutil.py index 2231d406..e16dbed9 100755 --- a/confluent_server/aiohmi/cmd/pyghmiutil.py +++ b/confluent_server/aiohmi/cmd/pyghmiutil.py @@ -17,6 +17,7 @@ it isn't conceived as a general utility to actually use, just help developers understand how the ipmi_command class workes. """ +import asyncio import functools import os import sys @@ -64,7 +65,7 @@ def docommand(args, result, ipmisession): data=map(lambda x: int(x, 16), args[2:]))) -def main(): +async def main(): if (len(sys.argv) < 3) or 'IPMIPASSWORD' not in os.environ: print("Usage:") print(" IPMIPASSWORD=password %s bmc username " % @@ -85,8 +86,8 @@ def main(): onlogon=functools.partial(docommand, sys.argv[3:])) if ipmicmd: - ipmicmd.eventloop() + await ipmicmd.eventloop() if __name__ == '__main__': - sys.exit(main()) + sys.exit(asyncio.run(main())) diff --git a/confluent_server/aiohmi/ipmi/console.py b/confluent_server/aiohmi/ipmi/console.py index 81965907..66312bdf 100644 --- a/confluent_server/aiohmi/ipmi/console.py +++ b/confluent_server/aiohmi/ipmi/console.py @@ -418,7 +418,7 @@ class Console(object): # sooner than timeout suggests is evidently a big deal await self.send_payload(payload=self.lastpayload, retry=False) - def main_loop(self): + async def main_loop(self): """Process all events until no more sessions exist. If a caller is a simple little utility, provide a function to @@ -431,7 +431,7 @@ class Console(object): # TODO(jbjohnso): wait_for_rsp is not returning a true value for our # own session while (1): - session.Session.wait_for_rsp(timeout=600) + await session.Session.wait_for_rsp(timeout=600) class ServerConsole(Console):