From c58ed04821e3b742192f1def5eb9f71cabf8714b Mon Sep 17 00:00:00 2001 From: Ruslan Date: Wed, 22 Jul 2026 08:10:20 +0000 Subject: [PATCH] fix: recycle webpool container on TERMINATED sessions too terminate_session_record was explicitly skipping WEBPOOLIDX containers. Now stops portal-webpool-N in a background thread on any session close, so ensure_web_pool recreates it fresh for the next user. --- app/runtime.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/app/runtime.py b/app/runtime.py index ff10eaf..bf6ce63 100644 --- a/app/runtime.py +++ b/app/runtime.py @@ -745,8 +745,15 @@ def terminate_session_record( return old_status = sess.status cid = sess.container_id or "" - if stop_container and cid and not cid.startswith(("POOL:", "POOLIDX:", "WEBPOOLIDX:", "RDPSLOT:")): - stop_runtime_container(cid) + if stop_container and cid: + if cid.startswith("WEBPOOLIDX:"): + try: + slot = int(cid.split(":", 1)[1]) + threading.Thread(target=stop_runtime_container, args=(web_pool_container_name(slot),), daemon=True).start() + except Exception: + logger.exception("webpool_slot_recycle_failed cid=%s", cid) + elif not cid.startswith(("POOL:", "POOLIDX:", "RDPSLOT:")): + stop_runtime_container(cid) if cid.startswith("RDPSLOT:"): try: slot_id = int(cid.split(":", 1)[1])