From 9ca700ee20990edd0efe2a50be93fe3d05431c5f Mon Sep 17 00:00:00 2001
From: Kepa Cantero <cantero@fortiss.org>
Date: Mon, 23 Sep 2019 11:55:37 +0000
Subject: [PATCH] Merged in distributed_not_closing_well (pull request #10)

[NRRPLT-0000] Distributed not killing the subprocess

Approved-by: Eloy Retamino <retamino@ugr.es>
Approved-by: Hossain Mahmud <hossain.mahmud@gmail.com>
---
 .../hbp_nrp_distributed_nest/launch/MPILauncher.py            | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/hbp_nrp_distributed_nest/hbp_nrp_distributed_nest/launch/MPILauncher.py b/hbp_nrp_distributed_nest/hbp_nrp_distributed_nest/launch/MPILauncher.py
index dc4fa1e..1b5fc8e 100644
--- a/hbp_nrp_distributed_nest/hbp_nrp_distributed_nest/launch/MPILauncher.py
+++ b/hbp_nrp_distributed_nest/hbp_nrp_distributed_nest/launch/MPILauncher.py
@@ -179,7 +179,8 @@ class MPILauncher(object):
     def _any_child_status(self, status):
         try:
             parent = psutil.Process(self._process.pid)
-            return any([
+            children = parent.children(recursive=True)
+            return not children or any([
                 child.status() in status
                 for child in parent.children(recursive=True)
             ])
@@ -220,7 +221,6 @@ class MPILauncher(object):
 
         while not self._any_child_status([psutil.STATUS_STOPPED, psutil.STATUS_ZOMBIE]):
             time.sleep(2)
-
         self._kill_children()
 
         if self._any_child_status([psutil.STATUS_SLEEPING, psutil.STATUS_RUNNING]):
-- 
GitLab