Skip to content

Commit

Permalink
api: Start control API conditionally (#300)
Browse files Browse the repository at this point in the history
- It should not always start, only if control_url is sent
- It should get the PipelineStreamer, not the result of handler.wait()
  • Loading branch information
victorges authored Dec 2, 2024
1 parent 0f5b66f commit 675f99a
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions runner/app/live/infer.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,14 @@ async def main(http_port: int, stream_protocol: str, subscribe_url: str, publish
try:
handler.start()
runner = await start_http_server(handler, http_port)
signal_task = asyncio.create_task(block_until_signal([signal.SIGINT, signal.SIGTERM]))
handler_task = asyncio.create_task(start_control_subscriber(handler.wait(), control_url))

await asyncio.wait([signal_task, handler_task],
tasks: List[asyncio.Task] = []
tasks.append(handler.wait())
tasks.append(asyncio.create_task(block_until_signal([signal.SIGINT, signal.SIGTERM])))
if control_url is not None and control_url.strip() != "":
tasks.append(asyncio.create_task(start_control_subscriber(handler, control_url)))

await asyncio.wait(tasks,
return_when=asyncio.FIRST_COMPLETED
)
except Exception as e:
Expand Down

0 comments on commit 675f99a

Please sign in to comment.