Compare commits
2 Commits
fc873e2d6b
...
268651bab0
| Author | SHA1 | Date | |
|---|---|---|---|
| 268651bab0 | |||
| 7389344b6d |
@@ -23,8 +23,14 @@ class TerminalManager:
|
|||||||
|
|
||||||
def _start_idle_check(self) -> None:
|
def _start_idle_check(self) -> None:
|
||||||
"""Start the idle timeout background task."""
|
"""Start the idle timeout background task."""
|
||||||
if self._idle_check_task is None or self._idle_check_task.done():
|
if self._idle_check_task is not None and not self._idle_check_task.done():
|
||||||
self._idle_check_task = asyncio.create_task(self._idle_check_loop())
|
return
|
||||||
|
try:
|
||||||
|
loop = asyncio.get_running_loop()
|
||||||
|
self._idle_check_task = loop.create_task(self._idle_check_loop())
|
||||||
|
except RuntimeError:
|
||||||
|
# No event loop running yet, will be started lazily
|
||||||
|
pass
|
||||||
|
|
||||||
async def _idle_check_loop(self) -> None:
|
async def _idle_check_loop(self) -> None:
|
||||||
"""Periodically check for idle sessions and clean them up."""
|
"""Periodically check for idle sessions and clean them up."""
|
||||||
@@ -54,6 +60,9 @@ class TerminalManager:
|
|||||||
container_id: str,
|
container_id: str,
|
||||||
) -> TerminalSession:
|
) -> TerminalSession:
|
||||||
"""Get existing session or create a new one."""
|
"""Get existing session or create a new one."""
|
||||||
|
# Ensure idle check is running (lazy start)
|
||||||
|
self._start_idle_check()
|
||||||
|
|
||||||
instance_id_str = str(instance_id)
|
instance_id_str = str(instance_id)
|
||||||
|
|
||||||
# Check for existing session
|
# Check for existing session
|
||||||
|
|||||||
Reference in New Issue
Block a user