File tree 3 files changed +24
-6
lines changed
3 files changed +24
-6
lines changed Original file line number Diff line number Diff line change @@ -52,7 +52,6 @@ def read_version():
52
52
"urllib3>=1.21.1,!=1.25,!=1.25.1" ,
53
53
"docker-compose>=1.25.2" ,
54
54
"PyYAML>=5.3, <6" , # PyYAML version has to match docker-compose requirements
55
- "psutil" ,
56
55
],
57
56
"scipy" : ["scipy>=0.19.0" ],
58
57
}
Original file line number Diff line number Diff line change 31
31
import tempfile
32
32
33
33
from distutils .spawn import find_executable
34
- from signal import SIGTERM
35
34
from threading import Thread
36
-
37
- import psutil
38
35
from six .moves .urllib .parse import urlparse
39
36
40
37
import sagemaker
@@ -843,8 +840,8 @@ def run(self):
843
840
844
841
def down (self ):
845
842
"""Placeholder docstring"""
846
- for process in psutil . Process ( self . process . pid ). children () :
847
- process . send_signal ( SIGTERM )
843
+ if os . name != 'nt' :
844
+ sagemaker . local . utils . kill_child_processes ( self . process . pid )
848
845
self .process .terminate ()
849
846
850
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