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

Function get_work_dir

Lib/test/libregrtest/utils.py:461–478  ·  view source on GitHub ↗
(parent_dir: StrPath, worker: bool = False)

Source from the content-addressed store, hash-verified

459
460
461def get_work_dir(parent_dir: StrPath, worker: bool = False) -> StrPath:
462 # Define a writable temp dir that will be used as cwd while running
463 # the tests. The name of the dir includes the pid to allow parallel
464 # testing (see the -j option).
465 # Emscripten and WASI have stubbed getpid(), Emscripten has only
466 # millisecond clock resolution. Use randint() instead.
467 if support.is_emscripten or support.is_wasi:
468 nounce = random.randint(0, 1_000_000)
469 else:
470 nounce = os.getpid()
471
472 if worker:
473 work_dir = WORK_DIR_PREFIX + str(nounce)
474 else:
475 work_dir = WORKER_WORK_DIR_PREFIX + str(nounce)
476 work_dir += os_helper.FS_NONASCII
477 work_dir = os.path.join(parent_dir, work_dir)
478 return work_dir
479
480
481@contextlib.contextmanager

Callers 2

run_testsMethod · 0.85
mainFunction · 0.85

Calls 3

strFunction · 0.85
randintMethod · 0.80
joinMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…