debug launch config

This commit is contained in:
John Lancaster
2026-08-29 21:06:02 -05:00
parent de95477480
commit c31a78206f
12 changed files with 207 additions and 49 deletions
+47
View File
@@ -0,0 +1,47 @@
import socket
import sys
from collections.abc import Iterator
import pytest
from xprocess import ProcessStarter
from xprocess import XProcess
SERVER_HOST = "127.0.0.1"
@pytest.fixture
def fastapi_server_url(xprocess: XProcess, unused_tcp_port: int) -> Iterator[str]:
class ServerStarter(ProcessStarter):
timeout = 10
terminate_on_interrupt = True
@property
def args(self) -> list[str]:
return [
sys.executable,
"-m",
"uvicorn",
"personal_mcp.app:create_app",
"--factory",
"--host",
SERVER_HOST,
"--port",
str(unused_tcp_port),
"--log-level",
"warning",
"--no-access-log",
]
def startup_check(self) -> bool:
try:
with socket.create_connection((SERVER_HOST, unused_tcp_port), timeout=0.1):
return True
except OSError:
return False
process_name = f"personal-mcp-http-{unused_tcp_port}"
xprocess.ensure(process_name, ServerStarter)
try:
yield f"http://{SERVER_HOST}:{unused_tcp_port}/mcp"
finally:
xprocess.getinfo(process_name).terminate()