add vnc streaming endpoints (#2695)

This commit is contained in:
Shuchang Zheng
2025-06-12 09:43:16 -07:00
committed by GitHub
parent c288c92138
commit 39a830ef6c
7 changed files with 744 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
import asyncio
from typing import Any, Sequence
async def collect(tasks: Sequence[asyncio.Task]) -> list[Any]:
"""
An alternative to 'gather'.
Waits for the first task to complete or fail, cancels others, and propagates
the first exception.
Returns the results of all tasks (if all tasks succeed).
"""
done, pending = await asyncio.wait(tasks, return_when=asyncio.FIRST_EXCEPTION)
for p in pending:
p.cancel()
await asyncio.gather(*pending, return_exceptions=True)
for task in done:
exc = task.exception()
if exc:
raise exc
return [task.result() for task in done]