File tree 2 files changed +24
-0
lines changed
2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -840,6 +840,8 @@ def run(self):
840
840
841
841
def down (self ):
842
842
"""Placeholder docstring"""
843
+ if os .name != 'nt' :
844
+ sagemaker .local .utils .kill_child_processes (self .process .pid )
843
845
self .process .terminate ()
844
846
845
847
Original file line number Diff line number Diff line change 15
15
16
16
import os
17
17
import shutil
18
+ import subprocess
18
19
19
20
from distutils .dir_util import copy_tree
20
21
from six .moves .urllib .parse import urlparse
@@ -88,3 +89,24 @@ def recursive_copy(source, destination):
88
89
"""
89
90
if os .path .isdir (source ):
90
91
copy_tree (source , destination )
92
+
93
+
94
+ def kill_child_processes (pid ):
95
+ child_pids = get_child_process_ids (pid )
96
+ for pid in child_pids :
97
+ os .kill (pid , 15 )
98
+
99
+
100
+ def get_child_process_ids (pid ):
101
+ cmd = f"pgrep -P { pid } " .split ()
102
+ output , err = subprocess .Popen (
103
+ cmd , stdout = subprocess .PIPE , stderr = subprocess .PIPE
104
+ ).communicate ()
105
+ if err :
106
+ return []
107
+ pids = [int (pid ) for pid in output .decode ('utf-8' ).split ()]
108
+ if pids :
109
+ for pid in pids :
110
+ return pids + get_child_process_ids (pid )
111
+ else :
112
+ return []
You can’t perform that action at this time.
0 commit comments