Skip to content

Commit 8215722

Browse files
committed
fix parallel
1 parent e94f152 commit 8215722

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

fastcore/utils.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -685,13 +685,12 @@ def _call(lock, pause, n, g, item):
685685
# Cell
686686
class ProcessPoolExecutor(concurrent.futures.ProcessPoolExecutor):
687687
"Same as Python's ProcessPoolExecutor, except can pass `max_workers==0` for serial execution"
688-
def __init__(self, max_workers=defaults.cpus, on_exc=print, pause=0,
689-
mp_context=None, initializer=None, initargs=(),):
688+
def __init__(self, max_workers=defaults.cpus, on_exc=print, pause=0, **kwargs):
690689
if max_workers is None: max_workers=defaults.cpus
691690
store_attr()
692691
self.not_parallel = max_workers==0
693692
if self.not_parallel: max_workers=1
694-
super().__init__(max_workers, mp_context=mp_context, initializer=initializer, initargs=initargs)
693+
super().__init__(max_workers, **kwargs)
695694

696695
def map(self, f, items, timeout=None, chunksize=1, *args, **kwargs):
697696
self.lock = Manager().Lock()

nbs/02_utils.ipynb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3577,13 +3577,12 @@
35773577
"#export\n",
35783578
"class ProcessPoolExecutor(concurrent.futures.ProcessPoolExecutor):\n",
35793579
" \"Same as Python's ProcessPoolExecutor, except can pass `max_workers==0` for serial execution\"\n",
3580-
" def __init__(self, max_workers=defaults.cpus, on_exc=print, pause=0,\n",
3581-
" mp_context=None, initializer=None, initargs=(),):\n",
3580+
" def __init__(self, max_workers=defaults.cpus, on_exc=print, pause=0, **kwargs):\n",
35823581
" if max_workers is None: max_workers=defaults.cpus\n",
35833582
" store_attr()\n",
35843583
" self.not_parallel = max_workers==0\n",
35853584
" if self.not_parallel: max_workers=1\n",
3586-
" super().__init__(max_workers, mp_context=mp_context, initializer=initializer, initargs=initargs)\n",
3585+
" super().__init__(max_workers, **kwargs)\n",
35873586
"\n",
35883587
" def map(self, f, items, timeout=None, chunksize=1, *args, **kwargs):\n",
35893588
" self.lock = Manager().Lock()\n",

0 commit comments

Comments
 (0)