Skip to content

Commit

Permalink
Launcher waits for process to get its web server up
Browse files Browse the repository at this point in the history
  • Loading branch information
raulikak committed Apr 30, 2024
1 parent 27db95d commit 2d31242
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tcsfw/launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import aiofiles
from aiohttp import web
import aiohttp

from tcsfw.client_api import APIRequest
from tcsfw.command_basics import get_authorization
Expand Down Expand Up @@ -191,6 +192,22 @@ async def wait_process():
asyncio.create_task(wait_process())

self.logger.info("Launched %s at port %s", key_str, client_port)

# wait for the process web server to start
ping_url = f"http://localhost:{client_port}/api1/ping"
self.logger.info("Pinging %s...", ping_url)
while True:
try:
async with aiohttp.ClientSession() as session:
async with session.get(ping_url) as resp:
if resp.status == 200:
break
except aiohttp.ClientConnectorError:
pass
await asyncio.sleep(0.1)
self.logger.info("...ping OK")


return client_port

async def save_stream_to_file(self, stream, file_path):
Expand Down

0 comments on commit 2d31242

Please sign in to comment.