Skip to content

Latest commit

 

History

History
30 lines (21 loc) · 506 Bytes

python-os.rst

File metadata and controls

30 lines (21 loc) · 506 Bytes

Operating System

Table of Contents

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)