Automation · Python Automation
Multiprocessing
Cheat sheet · https://pcornel.dk/topic.php?topic=5274
Answer
Python multiprocessing runs functions in separate processes with Pool or concurrent.futures.ProcessPoolExecutor, using several CPU cores for CPU-heavy automation tasks.
Remember
- Process pools run work on several CPU cores.
- They use more memory than threads.
- Arguments and results are pickled.
First checks
python3 -c 'import multiprocessing;print(multiprocessing.cpu_count())'— CPUs- concurrent.futures ThreadPoolExecutor/ProcessPoolExecutor — pools
- max_workers limit — target protection
Verify in this order
tasks → worker pool → results
Where it usually breaks
Input/desired state → request accepted → job/task terminal status → target object read-back → effective runtime state → original workload → regression/rollback readiness.
Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=5274