Skip to content

Commit

Permalink
Update os.py
Browse files Browse the repository at this point in the history
  • Loading branch information
corona10 committed Sep 30, 2023
1 parent 24fe0e4 commit 32843ed
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion Lib/os.py
Original file line number Diff line number Diff line change
Expand Up @@ -1138,7 +1138,18 @@ def add_dll_directory(path):
)


if _exists('sched_getaffinity'):
def _is_cpu_overrided():
is_overrided = False
env_opt = environ.get('PYTHONCPUCOUNT', None)
xopt = sys._xoptions.get('cpu_count', None)
if not any((env_opt, xopt)):
return False
if xopt == 'default':
return False
return True


if _exists('sched_getaffinity') and not _is_cpu_overrided():
def process_cpu_count():
"""
Get the number of CPUs of the current process.
Expand Down

0 comments on commit 32843ed

Please sign in to comment.