Skip to content

Commit ecc8325

Browse files
committed
Fix setup_multiprocessing.py to work on Macs.
1 parent 9856eb2 commit ecc8325

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

doc/source/examples/setup_multiprocessing.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@
55
os.environ["VECLIB_MAXIMUM_THREADS"] = "1"
66
os.environ["NUMEXPR_NUM_THREADS"] = "1"
77

8+
# I'm forcing the multiprocessing start method to 'fork' on Macs
9+
# because 'spawn' seems to cause errors with the numba code.
10+
from sys import platform
11+
if 'darwin' in platform:
12+
import multiprocessing as mp
13+
mp.set_start_method('fork')
14+
815
from numba import set_num_threads, config
9-
config.THREADING_LAYER = 'forksafe'
10-
set_num_threads(1)
16+
config.THREADING_LAYER = 'safe'
17+
set_num_threads(1)

0 commit comments

Comments
 (0)