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

Function _run_fork_script

tests/test_read_write_fork.py:307–327  ·  view source on GitHub ↗
(script: str, arguments: list[str], *, timeout: float)

Source from the content-addressed store, hash-verified

305
306
307def _run_fork_script(script: str, arguments: list[str], *, timeout: float) -> tuple[int, str, str]:
308 process = subprocess.Popen( # executes this test's fixed interpreter and source
309 [sys.executable, "-c", script, *arguments],
310 start_new_session=True,
311 stderr=subprocess.PIPE,
312 stdout=subprocess.PIPE,
313 text=True,
314 )
315 try:
316 process_output, process_error = process.communicate(timeout=timeout)
317 except subprocess.TimeoutExpired as error:
318 with contextlib.suppress(ProcessLookupError):
319 if sys.platform == "win32": # pragma: win32 cover
320 process.kill()
321 else: # pragma: win32 no cover
322 os.killpg(process.pid, signal.SIGKILL)
323 process_output, process_error = process.communicate()
324 msg = f"fork script exceeded {timeout} seconds: stdout={process_output!r}, stderr={process_error!r}"
325 raise AssertionError(msg) from error
326 assert process.returncode is not None # pragma: needs fork
327 return process.returncode, process_output, process_error # pragma: needs fork
328
329
330def _dropped_instances_script() -> str: # pragma: needs fd-directory

Calls

no outgoing calls

Tested by

no test coverage detected