Skip to content

Commit ee40bd6

Browse files
authored
fix control_subscriber task (#290)
1 parent b9bb93f commit ee40bd6

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

runner/app/live/infer.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,16 @@ async def main(http_port: int, stream_protocol: str, subscribe_url: str, publish
3333
try:
3434
handler.start()
3535
runner = await start_http_server(handler, http_port)
36-
asyncio.create_task(start_control_subscriber(handler, control_url))
36+
signal_task = asyncio.create_task(block_until_signal([signal.SIGINT, signal.SIGTERM]))
37+
handler_task = asyncio.create_task(start_control_subscriber(handler.wait(), control_url))
38+
39+
await asyncio.wait([signal_task, handler_task],
40+
return_when=asyncio.FIRST_COMPLETED
41+
)
3742
except Exception as e:
3843
logging.error(f"Error starting socket handler or HTTP server: {e}")
3944
logging.error(f"Stack trace:\n{traceback.format_exc()}")
4045
raise e
41-
42-
try:
43-
await asyncio.wait(
44-
[block_until_signal([signal.SIGINT, signal.SIGTERM]), handler.wait()],
45-
return_when=asyncio.FIRST_COMPLETED
46-
)
4746
finally:
4847
await runner.cleanup()
4948
await handler.stop()

0 commit comments

Comments
 (0)