Skip to content

Commit 711d5bb

Browse files
committed
patching some fallback to allow this to run on MacOS
1 parent de85e5d commit 711d5bb

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/dataclay/event_loop.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,13 @@
1515
# and we need to access the single event loop from the main thread.
1616
dc_event_loop: AbstractEventLoop = None
1717

18-
# Get available CPUs after numactl restriction
19-
cpu_count = len(psutil.Process().cpu_affinity())
18+
try:
19+
# Get available CPUs after numactl restriction
20+
cpu_count = len(psutil.Process().cpu_affinity())
21+
except AttributeError:
22+
# Fallback to the default CPU count if cpu_affinity is not available
23+
# (this happens, at least, on MacOS)
24+
cpu_count = psutil.cpu_count()
2025
# For CPU-bound tasks, use the number of CPUs available
2126
cpu_bound_executor = concurrent.futures.ThreadPoolExecutor(max_workers=cpu_count)
2227
# For I/O-bound tasks, use a higher multiplier

0 commit comments

Comments
 (0)