Approve context

This commit is contained in:
2024-11-02 19:17:27 +01:00
parent 96d14fc46d
commit 2a15708145
9 changed files with 296 additions and 149 deletions

View File

@@ -43,9 +43,20 @@ async def run_web_server():
await server.start()
try:
# Keep running until interrupted
while True:
await asyncio.sleep(1)
if server._response_tasks:
done, pending = await asyncio.wait(
server._response_tasks,
timeout=0.1,
return_when=asyncio.FIRST_COMPLETED
)
for task in done:
try:
await task
except Exception as e:
print(f"Task error: {e}")
server._response_tasks.remove(task)
await asyncio.sleep(0.1)
except KeyboardInterrupt:
print("\nShutting down...")
finally: