Operating System Table of Contents Get Number of CPUs Set Affinity Get Number of CPUs >>> import os >>> os.cpu_count() Set Affinity # run on linux import os pid = os.getpid() affinity = {1} os.sched_setaffinity(pid, affinity)