pikvm/pikvm#1485, pikvm/pikvm#187: kvmd-localhid to pass USB keyboard and mouse through PiKVM to the host

This commit is contained in:
Maxim Devaev
2025-05-23 23:44:59 +03:00
parent 625b2aa970
commit 310b23edad
11 changed files with 636 additions and 2 deletions

View File

@@ -211,6 +211,18 @@ async def wait_first(*aws: asyncio.Task) -> tuple[set[asyncio.Task], set[asyncio
return (await asyncio.wait(list(aws), return_when=asyncio.FIRST_COMPLETED))
# =====
async def spawn_and_follow(*coros: Coroutine) -> None:
tasks: list[asyncio.Task] = list(map(asyncio.create_task, coros))
try:
await asyncio.gather(*tasks)
except Exception:
for task in tasks:
task.cancel()
await asyncio.gather(*tasks, return_exceptions=True)
raise
# =====
async def close_writer(writer: asyncio.StreamWriter) -> bool:
closing = writer.is_closing()