Skip to content

Commit

Permalink
Improve the kill children processes (#2789)
Browse files Browse the repository at this point in the history
* use process.kill() to kill the children processes.

* removed the sig argument.

* removed no use import.
  • Loading branch information
yhwen authored Aug 13, 2024
1 parent 622f205 commit 138387e
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions nvflare/private/fed/app/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
# limitations under the License.

import os
import signal
import sys
import threading
import time
Expand Down Expand Up @@ -49,14 +48,14 @@ def check_parent_alive(parent_pid, stop_event: threading.Event):
time.sleep(1)


def kill_child_processes(parent_pid, sig=signal.SIGTERM):
def kill_child_processes(parent_pid):
try:
parent = psutil.Process(parent_pid)
except psutil.NoSuchProcess:
return
children = parent.children(recursive=True)
for process in children:
process.send_signal(sig)
process.kill()


def create_admin_server(fl_server: FederatedServer, server_conf=None, args=None, secure_train=False):
Expand Down

0 comments on commit 138387e

Please sign in to comment.