Skip to content

Commit d8eaff4

Browse files
committed
gh-84461: Fix parallel testing on WebAssembly
Emscripten and WASI have stubbed getpid() syscall that always returns the same value. Use time and random value instead of pid to create a unique working directory.
1 parent c5d0517 commit d8eaff4

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

Lib/test/libregrtest/main.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -628,7 +628,12 @@ def create_temp_dir(self):
628628
# Define a writable temp dir that will be used as cwd while running
629629
# the tests. The name of the dir includes the pid to allow parallel
630630
# testing (see the -j option).
631-
pid = os.getpid()
631+
# Emscripten and WASI have stubbed getpid(), Emscripten has only
632+
# milisecond clock resolution. Use time_ns() + randint() instead.
633+
if sys.platform in {"emscripten", "wasi"}:
634+
pid = time.time_ns() + random.randint(0, 1000000)
635+
else:
636+
pid = os.getpid()
632637
if self.worker_test_name is not None:
633638
test_cwd = 'test_python_worker_{}'.format(pid)
634639
else:

Tools/scripts/run_tests.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@ def main(regrtest_args):
6363
args.append('-n') # Silence alerts under Windows
6464
if not any(is_multiprocess_flag(arg) for arg in regrtest_args):
6565
if cross_compile and hostrunner:
66-
# For now use only one core for cross-compiled builds;
66+
# For now use only two cores for cross-compiled builds;
6767
# hostrunner can be expensive.
68-
args.extend(['-j', '1'])
68+
args.extend(['-j', '2'])
6969
else:
7070
args.extend(['-j', '0']) # Use all CPU cores
7171
if not any(is_resource_use_flag(arg) for arg in regrtest_args):

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy