Selenium + Python · Lesson 38 of 43
Module 38: Parallel Execution
Your task
Implement get_worker_count(cpu_count, max_workers=4):
Write it in the editor, then press Check answer (Ctrl + Enter).
pytest -nIn Python, each parallel worker is a separate OS process, eliminating GIL (Global Interpreter Lock) contention:
# Run tests across 4 parallel processes:
pytest -n 4
# Run with auto CPU detection:
pytest -n autoNever share browser instances or state across tests. Each test function must request a fresh browser fixture!
Welcome to Phase 6! Sequential test runs can take hours. In Python, parallel execution is achieved across multiple CPU cores using pytest-xdist. In this lesson, you will master test isolation and multi-process execution. Let's scale our tests!
Part of the Selenium + Python course (Selenium with Python). Practice this concept live in the Selenium Online Compiler or explore our free automation practice form.
Python processes provide completely isolated memory spaces, avoiding shared variable race conditions entirely.
Ready? Solve the task in the editor
Use Check answer to mark it complete. Hints are there if you need them.
___