Skip to content

Commit 4c25cdb

Browse files
fixes based on comments from code review
1 parent 9cda4a6 commit 4c25cdb

File tree

4 files changed

+7
-21
lines changed

4 files changed

+7
-21
lines changed

api/rest_server.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
)
3838

3939
# Async task storage (simple in-memory for now)
40+
# TODO: Replace with persistent storage (Redis/database) for production to survive server restarts
4041
async_tasks: Dict[str, Dict[str, Any]] = {}
4142

4243

@@ -69,7 +70,7 @@ async def health_check():
6970
session_count = len(session_manager.sessions)
7071

7172
# Check kernel pool
72-
from core.kernel_pool import kernel_pool
73+
from ..core.kernel_pool import kernel_pool
7374
kernel_status = {
7475
"total_kernels": len(kernel_pool.kernels),
7576
"available_kernels": len([k for k in kernel_pool.kernels.values() if k.is_available()]),

container_manager.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ class ContainerManager:
1818
"""Manage CodeRunner Docker container lifecycle"""
1919

2020
CONTAINER_NAME = "coderunner"
21-
REST_PORT = 8223
2221
MCP_PORT = 8222
2322
JUPYTER_PORT = 8888
2423
PLAYWRIGHT_PORT = 3000
@@ -175,7 +174,6 @@ def start_container(cls):
175174
subprocess.run([
176175
"docker", "run", "-d",
177176
"--name", cls.CONTAINER_NAME,
178-
"-p", f"{cls.REST_PORT}:8223",
179177
"-p", f"{cls.MCP_PORT}:8222",
180178
"-p", f"{cls.JUPYTER_PORT}:8888",
181179
"-p", f"{cls.PLAYWRIGHT_PORT}:3000",

core/session_manager.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ async def close_session(self, session_id: str) -> bool:
172172

173173
try:
174174
# Import here to avoid circular imports
175-
from server import kernel_pool
175+
from .kernel_pool import kernel_pool
176176

177177
# Release kernel back to pool
178178
await kernel_pool.release_kernel(session.kernel_id)

main.py

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,11 @@
1111
main_app.mount("/api", rest_app)
1212

1313
# Get the existing startup/shutdown events from REST API
14-
rest_startup = None
15-
rest_shutdown = None
16-
for event_handler in rest_app.router.on_startup:
17-
rest_startup = event_handler
14+
for handler in rest_app.router.on_startup:
15+
main_app.add_event_handler("startup", handler)
1816

19-
for event_handler in rest_app.router.on_shutdown:
20-
rest_shutdown = event_handler
21-
22-
# Add REST API startup/shutdown to main app
23-
if rest_startup:
24-
@main_app.on_event("startup")
25-
async def combined_startup():
26-
await rest_startup()
27-
28-
if rest_shutdown:
29-
@main_app.on_event("shutdown")
30-
async def combined_shutdown():
31-
await rest_shutdown()
17+
for handler in rest_app.router.on_shutdown:
18+
main_app.add_event_handler("shutdown", handler)
3219

3320
# Export the unified app
3421
app = main_app

0 commit comments

Comments
 (0)