refactor: remove dead code (safe cleanup)
- main.py: remove duplicate sqlalchemy select import - main.py: remove unused json import in _telegram_poll_loop - runtime.py: remove unreachable return after raise LockTimeoutError - runtime.py: remove _restart_rdp_slot_bg (defined but never called)
This commit is contained in:
@@ -701,27 +701,6 @@ def disconnect_rdp_slot(slot_id: int) -> None:
|
||||
db.close()
|
||||
|
||||
|
||||
def _restart_rdp_slot_bg(slot_id: int) -> None:
|
||||
db = SessionLocal()
|
||||
try:
|
||||
slot = db.get(RdpSlot, slot_id)
|
||||
if not slot or not slot.container_name:
|
||||
return
|
||||
service = db.get(Service, slot.service_id)
|
||||
if not service:
|
||||
return
|
||||
try:
|
||||
d = docker_client()
|
||||
c = d.containers.get(slot.container_name)
|
||||
c.restart(timeout=10)
|
||||
logger.info("rdp_slot_container_restarted slot_id=%s", slot_id)
|
||||
except docker.errors.NotFound:
|
||||
start_rdp_slot_container(slot, service)
|
||||
except Exception:
|
||||
logger.exception("rdp_slot_container_restart_failed slot_id=%s", slot_id)
|
||||
finally:
|
||||
db.close()
|
||||
|
||||
|
||||
def stop_runtime_container(container_id: Optional[str]) -> None:
|
||||
if not container_id:
|
||||
@@ -1093,8 +1072,6 @@ def allocator_lock(db: Session, lock_id: int, timeout_seconds: Optional[float] =
|
||||
time.sleep(max(0.01, poll_seconds))
|
||||
raise LockTimeoutError(f"advisory lock timeout lock_id={lock_id} timeout={timeout_seconds}")
|
||||
|
||||
return self_nonlocal
|
||||
|
||||
def __exit__(self_nonlocal, exc_type, exc, tb):
|
||||
return False
|
||||
|
||||
|
||||
Reference in New Issue
Block a user