[PATCH v2 5/6] tests: hwsim: add async infrastructure
Benjamin Berg
benjamin at sipsolutions.net
Mon Sep 14 04:00:48 PDT 2026
Hi,
On Sat, 2026-09-12 at 00:59 +0200, Johannes Berg wrote:
> [SNIP]
> +def _drive_sync(gen):
> + try:
> + req = next(gen)
> + while True:
> + req = gen.send(wpaspy.wait_event(*req))
> + except StopIteration as e:
> + return e.value
> +
> +async def _drive_async(gen):
> + try:
> + req = next(gen)
> + while True:
> + req = gen.send(await wpaspy.wait_event_async(*req))
> + except StopIteration as e:
> + return e.value
This seems overly complicated. The functions could simply be defined
with as async routines. Then _drive_async becomes a no-op while
_drive_sync can simply use asyncio.run, similar to how run_test_func
does it.
> [SNIP]
> - ev = dev2.wait_event(["DATA-TEST-RX"], timeout=timeout)
> + ev = yield (dev2.mon, ["DATA-TEST-RX"], timeout, dev2.dbg + ": ")
And then this could just become:
ev = await dv2.wait_event_async(["DATA-TEST-RX"], timeout=timeout)
Benjamin
> [SNIP]
More information about the Hostap
mailing list