Skip to content

Commit 144fd18

Browse files
krisctlprabhakk-mw
authored andcommitted
Improves process management during restart workflows with matlab-proxy-manager.
1 parent d3875a3 commit 144fd18

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

matlab_proxy_manager/lib/api.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,11 @@ async def _initialize_process_based_on_os_type(cmd, env):
253253
return await asyncio.create_subprocess_exec(
254254
*cmd,
255255
env=env,
256+
# kernel sporadically ends up cleaning the child matlab-proxy process during the
257+
# restart workflow. This is a workaround to handle that race condition which leads
258+
# to starting matlab-proxy in a new process group and is not counted for deletion.
259+
# https://github.com/ipython/ipykernel/blob/main/ipykernel/kernelbase.py#L1283
260+
start_new_session=True,
256261
)
257262
except Exception as e:
258263
log.error("Failed to create posix subprocess: %s", e)

matlab_proxy_manager/utils/helpers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,15 +153,15 @@ def _are_orphaned_servers_deleted(predicate: Optional[str] = "") -> bool:
153153
servers: dict = storage.get_all()
154154

155155
def _matches_predicate(filename: str) -> bool:
156-
return filename.split("_")[0] == predicate
156+
return filename.split("_")[0] == str(predicate)
157157

158158
# Checks only a subset of servers (that matches the parent_pid of the caller)
159159
# to reduce the MATLAB proxy startup time
160160
if predicate:
161161
servers = {
162162
filename: server
163163
for filename, server in servers.items()
164-
if _matches_predicate(filename)
164+
if _matches_predicate(Path(filename).stem)
165165
}
166166
if not servers:
167167
log.debug("Parent pid not matched, nothing to cleanup")

0 commit comments

Comments
 (0)