Skip to content

Commit 4f43be2

Browse files
authored
Merge pull request #422 from seeM/fix-parallel-macos
fix parallel on macos
2 parents 2fa2a63 + bdac978 commit 4f43be2

File tree

2 files changed

+9
-13
lines changed

2 files changed

+9
-13
lines changed

fastcore/parallel.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,12 @@
1010
from .xtras import *
1111
from functools import wraps
1212

13-
# from contextlib import contextmanager,ExitStack
1413
from multiprocessing import Process, Queue
1514
import concurrent.futures,time
1615
from multiprocessing import Manager, set_start_method
1716
from threading import Thread
18-
1917
try:
20-
if sys.platform == 'darwin': set_start_method("fork")
18+
if sys.platform == 'darwin' and IN_NOTEBOOK: set_start_method("fork")
2119
except: pass
2220

2321
# Cell

nbs/03a_parallel.ipynb

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,12 @@
2222
"from fastcore.xtras import *\n",
2323
"from functools import wraps\n",
2424
"\n",
25-
"# from contextlib import contextmanager,ExitStack\n",
2625
"from multiprocessing import Process, Queue\n",
2726
"import concurrent.futures,time\n",
2827
"from multiprocessing import Manager, set_start_method\n",
2928
"from threading import Thread\n",
30-
"\n",
3129
"try:\n",
32-
" if sys.platform == 'darwin': set_start_method(\"fork\")\n",
30+
" if sys.platform == 'darwin' and IN_NOTEBOOK: set_start_method(\"fork\")\n",
3331
"except: pass"
3432
]
3533
},
@@ -237,7 +235,7 @@
237235
"text/markdown": [
238236
"<h4 id=\"ThreadPoolExecutor\" class=\"doc_header\"><code>class</code> <code>ThreadPoolExecutor</code><a href=\"\" class=\"source_link\" style=\"float:right\">[source]</a></h4>\n",
239237
"\n",
240-
"> <code>ThreadPoolExecutor</code>(**`max_workers`**=*`64`*, **`on_exc`**=*`print`*, **`pause`**=*`0`*, **\\*\\*`kwargs`**) :: [`ThreadPoolExecutor`](/parallel.html#ThreadPoolExecutor)\n",
238+
"> <code>ThreadPoolExecutor</code>(**`max_workers`**=*`4`*, **`on_exc`**=*`print`*, **`pause`**=*`0`*, **\\*\\*`kwargs`**) :: [`ThreadPoolExecutor`](/parallel.html#ThreadPoolExecutor)\n",
241239
"\n",
242240
"Same as Python's ThreadPoolExecutor, except can pass `max_workers==0` for serial execution"
243241
],
@@ -292,7 +290,7 @@
292290
"text/markdown": [
293291
"<h4 id=\"ProcessPoolExecutor\" class=\"doc_header\"><code>class</code> <code>ProcessPoolExecutor</code><a href=\"\" class=\"source_link\" style=\"float:right\">[source]</a></h4>\n",
294292
"\n",
295-
"> <code>ProcessPoolExecutor</code>(**`max_workers`**=*`64`*, **`on_exc`**=*`print`*, **`pause`**=*`0`*, **\\*\\*`kwargs`**) :: [`ProcessPoolExecutor`](/parallel.html#ProcessPoolExecutor)\n",
293+
"> <code>ProcessPoolExecutor</code>(**`max_workers`**=*`4`*, **`on_exc`**=*`print`*, **`pause`**=*`0`*, **\\*\\*`kwargs`**) :: [`ProcessPoolExecutor`](/parallel.html#ProcessPoolExecutor)\n",
296294
"\n",
297295
"Same as Python's ProcessPoolExecutor, except can pass `max_workers==0` for serial execution"
298296
],
@@ -383,11 +381,11 @@
383381
"name": "stdout",
384382
"output_type": "stream",
385383
"text": [
386-
"0 2022-04-03 01:25:58.938402\n",
387-
"1 2022-04-03 01:25:59.189256\n",
388-
"2 2022-04-03 01:25:59.439853\n",
389-
"3 2022-04-03 01:25:59.691909\n",
390-
"4 2022-04-03 01:25:59.943055\n"
384+
"0 2022-06-30 09:28:21.811632\n",
385+
"1 2022-06-30 09:28:22.062815\n",
386+
"2 2022-06-30 09:28:22.314447\n",
387+
"3 2022-06-30 09:28:22.565210\n",
388+
"4 2022-06-30 09:28:22.816731\n"
391389
]
392390
}
393391
],

0 commit comments

Comments
 (0)