diff options
Diffstat (limited to 'Lib/os.py')
-rw-r--r-- | Lib/os.py | 14 |
1 files changed, 14 insertions, 0 deletions
@@ -1136,3 +1136,17 @@ if name == 'nt': cookie, nt._remove_dll_directory ) + + +if _exists('sched_getaffinity'): + def process_cpu_count(): + """ + Get the number of CPUs of the current process. + + Return the number of logical CPUs usable by the calling thread of the + current process. Return None if indeterminable. + """ + return len(sched_getaffinity(0)) +else: + # Just an alias to cpu_count() (same docstring) + process_cpu_count = cpu_count |