Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
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.
  • Loading branch information
tiran committed Jun 13, 2022
commit d8eaff4fa4bcbd1d0840f757d29a65e5bf26458c
7 changes: 6 additions & 1 deletion Lib/test/libregrtest/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,12 @@ def create_temp_dir(self):
# Define a writable temp dir that will be used as cwd while running
# the tests. The name of the dir includes the pid to allow parallel
# testing (see the -j option).
pid = os.getpid()
# Emscripten and WASI have stubbed getpid(), Emscripten has only
# milisecond clock resolution. Use time_ns() + randint() instead.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why use time.time_ns if it has only "milisecond clock resolution"?

if sys.platform in {"emscripten", "wasi"}:
pid = time.time_ns() + random.randint(0, 1000000)
Comment thread
tiran marked this conversation as resolved.
Outdated
else:
pid = os.getpid()
if self.worker_test_name is not None:
test_cwd = 'test_python_worker_{}'.format(pid)
else:
Expand Down
4 changes: 2 additions & 2 deletions Tools/scripts/run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ def main(regrtest_args):
args.append('-n') # Silence alerts under Windows
if not any(is_multiprocess_flag(arg) for arg in regrtest_args):
if cross_compile and hostrunner:
# For now use only one core for cross-compiled builds;
# For now use only two cores for cross-compiled builds;
# hostrunner can be expensive.
args.extend(['-j', '1'])
args.extend(['-j', '2'])
else:
args.extend(['-j', '0']) # Use all CPU cores
if not any(is_resource_use_flag(arg) for arg in regrtest_args):
Expand Down