From 382604e923857b9c99b265afe65e57a427c1021a Mon Sep 17 00:00:00 2001 From: allegroai <> Date: Wed, 30 Jun 2021 23:58:25 +0300 Subject: [PATCH] Fix services mode killing child processes when running in services mode + venv --- clearml_agent/commands/worker.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/clearml_agent/commands/worker.py b/clearml_agent/commands/worker.py index 2be68d6..9c81071 100644 --- a/clearml_agent/commands/worker.py +++ b/clearml_agent/commands/worker.py @@ -1456,15 +1456,15 @@ class Worker(ServiceCommandSection): stop_reason = TaskStopReason.exception status = -1 - # full cleanup (just in case) - if process: - kill_all_child_processes(process.pid) - # if running in services mode, keep the file open # in case the docker was so quick it started and finished, check the stop reason if self._services_mode and service_mode_internal_agent_started and stop_reason == 'Service started': return None, None + # full cleanup (just in case) + if process and not self._services_mode: + kill_all_child_processes(process.pid) + stdout.close() if stderr_path: stderr.close()