操作系统

获取CPU数量

>>> import os
>>> os.cpu_count()

设置亲和性

# run on linux
import os

pid = os.getpid()
affinity = {1}
os.sched_setaffinity(pid, affinity)