MCPcopy Create free account
hub / github.com/tox-dev/filelock / cleanup_processes

Function cleanup_processes

tests/process_helpers.py:23–36  ·  view source on GitHub ↗
(processes: list[BaseProcess])

Source from the content-addressed store, hash-verified

21
22@contextmanager
23def cleanup_processes(processes: list[BaseProcess]) -> Generator[None]:
24 try:
25 yield
26 finally:
27 for process in processes:
28 # Terminating an unstarted process raises over the assertion that escaped before it started.
29 if process.pid is not None:
30 process.terminate()
31 process.join(timeout=_REAP_DEADLINE)
32 if process.is_alive(): # pragma: no cover # SIGTERM only loses this race on a saturated runner
33 process.kill()
34 process.join(timeout=_REAP_DEADLINE)
35 # Left open, the finalizer runs during whichever test the collector lands in, as an unraisable exception.
36 process.close()
37
38
39def break_then_hang_after_exchange(

Calls 2

joinMethod · 0.80
closeMethod · 0.45