fix: arcade dev waits forever if no toolkits are installed (#147)

Fixes an edge case where the actor doesn't start because no toolkits are
installed in the local environment, but `arcade dev` keeps waiting for a
healthy actor.
This commit is contained in:
Nate Barbettini 2024-11-05 13:37:39 -08:00 committed by GitHub
parent bc393db305
commit 29ccf19e73
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 18 additions and 8 deletions

11
.vscode/launch.json vendored
View file

@ -39,6 +39,17 @@
"justMyCode": true,
"cwd": "${workspaceFolder}"
},
{
"name": "Debug `arcade dev`",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}/arcade/run_cli.py",
"args": ["dev"],
"console": "integratedTerminal",
"jinja": true,
"justMyCode": true,
"cwd": "${workspaceFolder}"
},
{
"name": "Debug `arcade evals -d` on current file",
"type": "python",

View file

@ -364,7 +364,7 @@ def _wait_for_healthy_actor(
) -> None:
"""Wait until an HTTP request to `host:port/actor/health` returns 200"""
while not actor_process.poll(): # Stop waiting if the actor process has exited
while actor_process.poll() is None: # Continue waiting UNLESS the actor process has exited
time.sleep(1)
try:
conn = http.client.HTTPConnection(actor_host, actor_port, timeout=1)

View file

@ -98,13 +98,12 @@ def serve_default_actor(
toolkits = Toolkit.find_all_arcade_toolkits()
if not toolkits:
logger.error("No toolkits found in Python environment. Exiting...")
return
else:
logger.info("Serving the following toolkits:")
for toolkit in toolkits:
num_tools = sum(len(tools) for tools in toolkit.tools.values())
logger.info(f" - {toolkit.name} ({toolkit.package_name}): {num_tools} tools")
raise RuntimeError("No toolkits found in Python environment.")
logger.info("Serving the following toolkits:")
for toolkit in toolkits:
num_tools = sum(len(tools) for tools in toolkit.tools.values())
logger.info(f" - {toolkit.name} ({toolkit.package_name}): {num_tools} tools")
actor_secret = os.environ.get("ARCADE_ACTOR_SECRET")
if not disable_auth and not actor_secret: