Skip to content

Commit 00625f9

Browse files
committed
fixes #86
1 parent 72178fa commit 00625f9

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

fastcore/utils.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -678,13 +678,12 @@ def _call(lock, pause, n, g, item):
678678
# Cell
679679
class ProcessPoolExecutor(concurrent.futures.ProcessPoolExecutor):
680680
"Same as Python's ProcessPoolExecutor, except can pass `max_workers==0` for serial execution"
681-
def __init__(self, max_workers=defaults.cpus, on_exc=print, pause=0,
682-
mp_context=None, initializer=None, initargs=(),):
681+
def __init__(self, max_workers=defaults.cpus, on_exc=print, pause=0, **kwargs):
683682
if max_workers is None: max_workers=defaults.cpus
684683
store_attr()
685684
self.not_parallel = max_workers==0
686685
if self.not_parallel: max_workers=1
687-
super().__init__(max_workers, mp_context=mp_context, initializer=initializer, initargs=initargs)
686+
super().__init__(max_workers, **kwargs)
688687

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

nbs/02_utils.ipynb

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@
294294
{
295295
"data": {
296296
"text/plain": [
297-
"<__main__._t at 0x7fd7b4badb90>"
297+
"<__main__._t at 0x7fd2eaf8cf50>"
298298
]
299299
},
300300
"execution_count": null,
@@ -1625,7 +1625,7 @@
16251625
{
16261626
"data": {
16271627
"text/plain": [
1628-
"['a', 'e', 'b', 'h', 'c', 'd', 'g', 'f']"
1628+
"['g', 'e', 'f', 'a', 'h', 'c', 'd', 'b']"
16291629
]
16301630
},
16311631
"execution_count": null,
@@ -3511,13 +3511,12 @@
35113511
"#export\n",
35123512
"class ProcessPoolExecutor(concurrent.futures.ProcessPoolExecutor):\n",
35133513
" \"Same as Python's ProcessPoolExecutor, except can pass `max_workers==0` for serial execution\"\n",
3514-
" def __init__(self, max_workers=defaults.cpus, on_exc=print, pause=0,\n",
3515-
" mp_context=None, initializer=None, initargs=(),):\n",
3514+
" def __init__(self, max_workers=defaults.cpus, on_exc=print, pause=0, **kwargs):\n",
35163515
" if max_workers is None: max_workers=defaults.cpus\n",
35173516
" store_attr()\n",
35183517
" self.not_parallel = max_workers==0\n",
35193518
" if self.not_parallel: max_workers=1\n",
3520-
" super().__init__(max_workers, mp_context=mp_context, initializer=initializer, initargs=initargs)\n",
3519+
" super().__init__(max_workers, **kwargs)\n",
35213520
"\n",
35223521
" def map(self, f, items, timeout=None, chunksize=1, *args, **kwargs):\n",
35233522
" self.lock = Manager().Lock()\n",
@@ -3538,7 +3537,7 @@
35383537
"text/markdown": [
35393538
"<h4 id=\"ProcessPoolExecutor\" class=\"doc_header\"><code>class</code> <code>ProcessPoolExecutor</code><a href=\"\" class=\"source_link\" style=\"float:right\">[source]</a></h4>\n",
35403539
"\n",
3541-
"> <code>ProcessPoolExecutor</code>(**`max_workers`**=*`64`*, **`on_exc`**=*`print`*, **`pause`**=*`0`*, **`mp_context`**=*`None`*, **`initializer`**=*`None`*, **`initargs`**=*`()`*) :: [`ProcessPoolExecutor`](/utils.html#ProcessPoolExecutor)\n",
3540+
"> <code>ProcessPoolExecutor</code>(**`max_workers`**=*`64`*, **`on_exc`**=*`print`*, **`pause`**=*`0`*, **\\*\\*`kwargs`**) :: [`ProcessPoolExecutor`](/utils.html#ProcessPoolExecutor)\n",
35423541
"\n",
35433542
"Same as Python's ProcessPoolExecutor, except can pass `max_workers==0` for serial execution"
35443543
],
@@ -3554,6 +3553,13 @@
35543553
"show_doc(ProcessPoolExecutor, title_level=4)"
35553554
]
35563555
},
3556+
{
3557+
"cell_type": "markdown",
3558+
"metadata": {},
3559+
"source": [
3560+
"`kwargs` are passed to Python's [`concurrent.futures.ProcessPoolExecutor`](https://python.readthedocs.io/en/latest/library/concurrent.futures.html#processpoolexecutor), so depend on your python version. From Python 3.7, they are: `mp_context=None`, `initializer=None`, `initargs=()`."
3561+
]
3562+
},
35573563
{
35583564
"cell_type": "code",
35593565
"execution_count": null,

0 commit comments

Comments
 (0)