Skip to content

Commit 14c92c8

Browse files
committed
Fix process cleanup
1 parent b1e3149 commit 14c92c8

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

tests/utils.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,21 @@ def _ping(port: int) -> bool:
4040
def kill_process(process: Process):
4141
pid = process.pid
4242
process.terminate()
43-
process.kill()
44-
_wait_for_process_to_die(process)
43+
# allow the process a moment to exit cleanly
44+
process.join(timeout=5)
45+
if process.is_alive():
46+
process.kill()
47+
_wait_for_process_to_die(process, timeout=5)
4548
process.join()
4649
if pid and pid in process_map:
4750
del process_map[pid]
4851

4952

50-
def _wait_for_process_to_die(process, timeout: int = 5):
53+
def _wait_for_process_to_die(process, timeout: float = 5.0):
5154
start = time.time()
5255
while time.time() - start < timeout:
5356
if not process.is_alive():
57+
process.join()
5458
return
5559
time.sleep(0.1)
5660

0 commit comments

Comments
 (0)