MCPcopy Index your code
hub / github.com/python/cpython / run_tmp_files

Method run_tmp_files

Lib/test/libregrtest/run_workers.py:287–308  ·  view source on GitHub ↗
(self, worker_runtests: WorkerRunTests,
                      stdout_fd: int)

Source from the content-addressed store, hash-verified

285 **kwargs)
286
287 def run_tmp_files(self, worker_runtests: WorkerRunTests,
288 stdout_fd: int) -> tuple[int | None, list[StrPath]]:
289 # gh-93353: Check for leaked temporary files in the parent process,
290 # since the deletion of temporary files can happen late during
291 # Python finalization: too late for libregrtest.
292 if not support.is_wasi:
293 # Don't check for leaked temporary files and directories if Python is
294 # run on WASI. WASI doesn't pass environment variables like TMPDIR to
295 # worker processes.
296 tmp_dir = tempfile.mkdtemp(prefix="test_python_")
297 tmp_dir = os.path.abspath(tmp_dir)
298 try:
299 retcode = self._run_process(worker_runtests,
300 stdout_fd, tmp_dir)
301 finally:
302 tmp_files = os.listdir(tmp_dir)
303 os_helper.rmtree(tmp_dir)
304 else:
305 retcode = self._run_process(worker_runtests, stdout_fd)
306 tmp_files = []
307
308 return (retcode, tmp_files)
309
310 def read_stdout(self, stdout_file: TextIO) -> str:
311 stdout_file.seek(0)

Callers 1

_runtestMethod · 0.95

Calls 4

_run_processMethod · 0.95
mkdtempMethod · 0.80
listdirMethod · 0.80
abspathMethod · 0.45

Tested by

no test coverage detected