Skip to content

Commit

Permalink
Mac OS support for cpu_count
Browse files Browse the repository at this point in the history
  • Loading branch information
kzfm committed Oct 11, 2024
1 parent a243607 commit be8d024
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion maize/utilities/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import os
import subprocess
import time
import multiprocessing
from typing import TYPE_CHECKING, TypeVar, Any

from maize.core.runtime import Status
Expand Down Expand Up @@ -41,7 +42,10 @@ def cpu_count() -> int:
the affinity to make it compatible with cluster management systems.
"""
return len(os.sched_getaffinity(0))
try:
return len(os.sched_getaffinity(0))
except AttributeError:
return multiprocessing.cpu_count()

# Only reference to something like this that I've found is:
# https://stackoverflow.com/questions/69366850/counting-semaphore-that-supports-multiple-acquires-in-an-atomic-call-how-would
Expand Down

0 comments on commit be8d024

Please sign in to comment.