File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change 8
8
import logging
9
9
import os
10
10
import signal
11
+ import subprocess # nosec
11
12
import sys
12
13
import time
13
14
import urllib
@@ -112,7 +113,18 @@ def _terminate_processes() -> None:
112
113
# It's possible that another thread will spawn a new task while
113
114
# we're executing, so it's not safe to use a for loop here.
114
115
while processes_to_kill :
115
- processes_to_kill .popleft ().kill ()
116
+ process = processes_to_kill .popleft ()
117
+ cidfile = [str (arg ).split ("=" )[1 ] for arg in process .args if "--cidfile" in str (arg )]
118
+ if cidfile :
119
+ try :
120
+ with open (cidfile [0 ], "r" ) as inp_stream :
121
+ p = subprocess .Popen (["docker" , "kill" , inp_stream .read ()], shell = False ) # nosec
122
+ try :
123
+ p .wait (timeout = 10 )
124
+ except subprocess .TimeoutExpired :
125
+ p .kill ()
126
+ except FileNotFoundError :
127
+ pass
116
128
117
129
118
130
def _signal_handler (signum : int , _ : Any ) -> None :
You can’t perform that action at this time.
0 commit comments