2
0
mirror of https://github.com/xcat2/confluent.git synced 2026-08-28 01:26:44 +00:00

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.
This commit is contained in:
Markus Hilger
2026-08-10 04:39:28 +02:00
parent 92c9abc74a
commit b96d4b4103
3 changed files with 10 additions and 8 deletions
+4 -3
View File
@@ -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()))
+4 -3
View File
@@ -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 <cmd> <optarg>" %
@@ -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()))
+2 -2
View File
@@ -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):