Skip to content

Commit 2bfeec5

Browse files
committed
fixes #246
1 parent a6a2df9 commit 2bfeec5

File tree

2 files changed

+23
-32
lines changed

2 files changed

+23
-32
lines changed

fastcore/parallel.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def __init__(self, max_workers=defaults.cpus, on_exc=print, pause=0, **kwargs):
6363
if self.not_parallel: max_workers=1
6464
super().__init__(max_workers, **kwargs)
6565

66-
def map(self, f, items, timeout=None, chunksize=1, *args, **kwargs):
66+
def map(self, f, items, *args, timeout=None, chunksize=1, **kwargs):
6767
self.lock = Manager().Lock()
6868
g = partial(f, *args, **kwargs)
6969
if self.not_parallel: return map(g, items)
@@ -81,7 +81,7 @@ def __init__(self, max_workers=defaults.cpus, on_exc=print, pause=0, **kwargs):
8181
if self.not_parallel: max_workers=1
8282
super().__init__(max_workers, **kwargs)
8383

84-
def map(self, f, items, timeout=None, chunksize=1, *args, **kwargs):
84+
def map(self, f, items, *args, timeout=None, chunksize=1, **kwargs):
8585
self.lock = Manager().Lock()
8686
g = partial(f, *args, **kwargs)
8787
if self.not_parallel: return map(g, items)

nbs/03a_parallel.ipynb

Lines changed: 21 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,7 @@
7070
"cell_type": "code",
7171
"execution_count": null,
7272
"metadata": {},
73-
"outputs": [
74-
{
75-
"name": "stdout",
76-
"output_type": "stream",
77-
"text": [
78-
"first\n"
79-
]
80-
}
81-
],
73+
"outputs": [],
8274
"source": [
8375
"@threaded\n",
8476
"def _1():\n",
@@ -110,7 +102,15 @@
110102
"cell_type": "code",
111103
"execution_count": null,
112104
"metadata": {},
113-
"outputs": [],
105+
"outputs": [
106+
{
107+
"name": "stdout",
108+
"output_type": "stream",
109+
"text": [
110+
"first\n"
111+
]
112+
}
113+
],
114114
"source": [
115115
"@startthread\n",
116116
"def _():\n",
@@ -160,8 +160,7 @@
160160
"name": "stdout",
161161
"output_type": "stream",
162162
"text": [
163-
"firstsecond\n",
164-
"\n"
163+
"first\n"
165164
]
166165
}
167166
],
@@ -194,7 +193,7 @@
194193
" if self.not_parallel: max_workers=1\n",
195194
" super().__init__(max_workers, **kwargs)\n",
196195
"\n",
197-
" def map(self, f, items, timeout=None, chunksize=1, *args, **kwargs):\n",
196+
" def map(self, f, items, *args, timeout=None, chunksize=1, **kwargs):\n",
198197
" self.lock = Manager().Lock()\n",
199198
" g = partial(f, *args, **kwargs)\n",
200199
" if self.not_parallel: return map(g, items)\n",
@@ -219,7 +218,7 @@
219218
" if self.not_parallel: max_workers=1\n",
220219
" super().__init__(max_workers, **kwargs)\n",
221220
"\n",
222-
" def map(self, f, items, timeout=None, chunksize=1, *args, **kwargs):\n",
221+
" def map(self, f, items, *args, timeout=None, chunksize=1, **kwargs):\n",
223222
" self.lock = Manager().Lock()\n",
224223
" g = partial(f, *args, **kwargs)\n",
225224
" if self.not_parallel: return map(g, items)\n",
@@ -238,7 +237,7 @@
238237
"text/markdown": [
239238
"<h4 id=\"ProcessPoolExecutor\" class=\"doc_header\"><code>class</code> <code>ProcessPoolExecutor</code><a href=\"\" class=\"source_link\" style=\"float:right\">[source]</a></h4>\n",
240239
"\n",
241-
"> <code>ProcessPoolExecutor</code>(**`max_workers`**=*`64`*, **`on_exc`**=*`print`*, **`pause`**=*`0`*, **\\*\\*`kwargs`**) :: [`ProcessPoolExecutor`](/03a.html#ProcessPoolExecutor)\n",
240+
"> <code>ProcessPoolExecutor</code>(**`max_workers`**=*`64`*, **`on_exc`**=*`print`*, **`pause`**=*`0`*, **\\*\\*`kwargs`**) :: [`ProcessPoolExecutor`](/parallel.html#ProcessPoolExecutor)\n",
242241
"\n",
243242
"Same as Python's ProcessPoolExecutor, except can pass `max_workers==0` for serial execution"
244243
],
@@ -258,15 +257,7 @@
258257
"cell_type": "code",
259258
"execution_count": null,
260259
"metadata": {},
261-
"outputs": [
262-
{
263-
"name": "stdout",
264-
"output_type": "stream",
265-
"text": [
266-
"second\n"
267-
]
268-
}
269-
],
260+
"outputs": [],
270261
"source": [
271262
"#export\n",
272263
"try: from fastprogress import progress_bar\n",
@@ -377,11 +368,11 @@
377368
"name": "stdout",
378369
"output_type": "stream",
379370
"text": [
380-
"0 2020-11-27 09:27:28.845698\n",
381-
"1 2020-11-27 09:27:29.096662\n",
382-
"2 2020-11-27 09:27:29.347888\n",
383-
"3 2020-11-27 09:27:29.597825\n",
384-
"4 2020-11-27 09:27:29.849458\n"
371+
"0 2020-12-11 18:28:04.960255\n",
372+
"1 2020-12-11 18:28:05.211221\n",
373+
"2 2020-12-11 18:28:05.461427\n",
374+
"3 2020-12-11 18:28:05.711582\n",
375+
"4 2020-12-11 18:28:05.962502\n"
385376
]
386377
}
387378
],
@@ -537,7 +528,7 @@
537528
"Converted 01_basics.ipynb.\n",
538529
"Converted 02_foundation.ipynb.\n",
539530
"Converted 03_xtras.ipynb.\n",
540-
"Converted 03a.ipynb.\n",
531+
"Converted 03a_parallel.ipynb.\n",
541532
"Converted 03b_net.ipynb.\n",
542533
"Converted 04_dispatch.ipynb.\n",
543534
"Converted 05_transform.ipynb.\n",

0 commit comments

Comments
 (0)