Automation · Parallelism & Concurrency
Threading
Cheat sheet · https://pcornel.dk/topic.php?topic=5988
Answer
Threading runs several threads in one process sharing memory, useful for I/O-bound automation like SSH to many devices. Shared data must be protected, and in Python CPU-bound work does not speed up.
Remember
- Good for SSH to many devices.
- Protect shared data.
- Python GIL limits CPU work.
First checks
- ThreadPoolExecutor(max_workers=N) — bounded threads
- Thread-safe data structures — safety
- GIL awareness (I/O-bound OK) — performance
Verify in this order
tasks → thread 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=5988