Skip to content

Commit 1419852

Browse files
committed
fixes #761
1 parent 699a9ff commit 1419852

3 files changed

Lines changed: 353 additions & 118 deletions

File tree

fastcore/parallel.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ def g(_obj_td, *args, **kwargs):
3030
_obj_td.result = res
3131
@wraps(f)
3232
def _f(*args, **kwargs):
33-
res = (Thread,Process)[process](target=g, args=args, kwargs=kwargs)
33+
Proc = get_context('fork').Process if sys.platform == 'darwin' else Process
34+
res = (Thread,Proc)[process](target=g, args=args, kwargs=kwargs)
3435
res._args = (res,)+res._args
3536
res.start()
3637
return res
@@ -158,7 +159,8 @@ async def limited_task(item):
158159
# %% ../nbs/03a_parallel.ipynb #da364301
159160
def run_procs(f, f_done, args):
160161
"Call `f` for each item in `args` in parallel, yielding `f_done`"
161-
processes = L(args).map(Process, args=arg0, target=f)
162+
Proc = get_context('fork').Process if sys.platform == 'darwin' else Process
163+
processes = L(args).map(Proc, args=arg0, target=f)
162164
for o in processes: o.start()
163165
yield from f_done()
164166
processes.map(Self.join())

nbs/02_foundation.ipynb

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4416,27 +4416,6 @@
44164416
"You can use `Config.find` to search subdirectories for a config file, starting in the current path if no path is specified:"
44174417
]
44184418
},
4419-
{
4420-
"cell_type": "code",
4421-
"execution_count": null,
4422-
"id": "5f858954",
4423-
"metadata": {},
4424-
"outputs": [
4425-
{
4426-
"data": {
4427-
"text/plain": [
4428-
"'fastcore'"
4429-
]
4430-
},
4431-
"execution_count": null,
4432-
"metadata": {},
4433-
"output_type": "execute_result"
4434-
}
4435-
],
4436-
"source": [
4437-
"Config.find('settings.ini').repo"
4438-
]
4439-
},
44404419
{
44414420
"cell_type": "markdown",
44424421
"id": "c856bdd5",
@@ -4457,7 +4436,10 @@
44574436
]
44584437
}
44594438
],
4460-
"metadata": {},
4439+
"metadata": {
4440+
"solveit_dialog_mode": "learning",
4441+
"solveit_ver": 2
4442+
},
44614443
"nbformat": 4,
44624444
"nbformat_minor": 5
44634445
}

0 commit comments

Comments
 (0)