Skip to content

Commit 3e7bb77

Browse files
committed
fix test
1 parent 2bfeec5 commit 3e7bb77

File tree

4 files changed

+60
-29
lines changed

4 files changed

+60
-29
lines changed

fastcore/_nbdev.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,8 @@
172172
"threaded": "03a_parallel.ipynb",
173173
"startthread": "03a_parallel.ipynb",
174174
"set_num_threads": "03a_parallel.ipynb",
175-
"ProcessPoolExecutor": "03a_parallel.ipynb",
176175
"ThreadPoolExecutor": "03a_parallel.ipynb",
176+
"ProcessPoolExecutor": "03a_parallel.ipynb",
177177
"parallel": "03a_parallel.ipynb",
178178
"run_procs": "03a_parallel.ipynb",
179179
"parallel_gen": "03a_parallel.ipynb",

fastcore/parallel.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# AUTOGENERATED! DO NOT EDIT! File to edit: nbs/03a_parallel.ipynb (unless otherwise specified).
22

3-
__all__ = ['threaded', 'startthread', 'set_num_threads', 'ProcessPoolExecutor', 'ThreadPoolExecutor', 'parallel',
3+
__all__ = ['threaded', 'startthread', 'set_num_threads', 'ThreadPoolExecutor', 'ProcessPoolExecutor', 'parallel',
44
'run_procs', 'parallel_gen']
55

66
# Cell
@@ -54,8 +54,8 @@ def _call(lock, pause, n, g, item):
5454
return g(item)
5555

5656
# Cell
57-
class ProcessPoolExecutor(concurrent.futures.ProcessPoolExecutor):
58-
"Same as Python's ProcessPoolExecutor, except can pass `max_workers==0` for serial execution"
57+
class ThreadPoolExecutor(concurrent.futures.ThreadPoolExecutor):
58+
"Same as Python's ThreadPoolExecutor, except can pass `max_workers==0` for serial execution"
5959
def __init__(self, max_workers=defaults.cpus, on_exc=print, pause=0, **kwargs):
6060
if max_workers is None: max_workers=defaults.cpus
6161
store_attr()
@@ -72,8 +72,8 @@ def map(self, f, items, *args, timeout=None, chunksize=1, **kwargs):
7272
except Exception as e: self.on_exc(e)
7373

7474
# Cell
75-
class ThreadPoolExecutor(concurrent.futures.ThreadPoolExecutor):
76-
"Same as Python's ThreadPoolExecutor, except can pass `max_workers==0` for serial execution"
75+
class ProcessPoolExecutor(concurrent.futures.ProcessPoolExecutor):
76+
"Same as Python's ProcessPoolExecutor, except can pass `max_workers==0` for serial execution"
7777
def __init__(self, max_workers=defaults.cpus, on_exc=print, pause=0, **kwargs):
7878
if max_workers is None: max_workers=defaults.cpus
7979
store_attr()

nbs/03a_parallel.ipynb

Lines changed: 53 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,16 @@
7070
"cell_type": "code",
7171
"execution_count": null,
7272
"metadata": {},
73-
"outputs": [],
73+
"outputs": [
74+
{
75+
"name": "stdout",
76+
"output_type": "stream",
77+
"text": [
78+
"first\n",
79+
"second\n"
80+
]
81+
}
82+
],
7483
"source": [
7584
"@threaded\n",
7685
"def _1():\n",
@@ -83,7 +92,8 @@
8392
" print(\"first\")\n",
8493
"\n",
8594
"_1()\n",
86-
"_2();"
95+
"_2()\n",
96+
"time.sleep(0.1)"
8797
]
8898
},
8999
{
@@ -107,7 +117,8 @@
107117
"name": "stdout",
108118
"output_type": "stream",
109119
"text": [
110-
"first\n"
120+
"first\n",
121+
"second\n"
111122
]
112123
}
113124
],
@@ -120,7 +131,9 @@
120131
"@startthread\n",
121132
"def _():\n",
122133
" time.sleep(0.01)\n",
123-
" print(\"first\")"
134+
" print(\"first\")\n",
135+
"\n",
136+
"time.sleep(0.1)"
124137
]
125138
},
126139
{
@@ -155,15 +168,7 @@
155168
"cell_type": "code",
156169
"execution_count": null,
157170
"metadata": {},
158-
"outputs": [
159-
{
160-
"name": "stdout",
161-
"output_type": "stream",
162-
"text": [
163-
"first\n"
164-
]
165-
}
166-
],
171+
"outputs": [],
167172
"source": [
168173
"#export\n",
169174
"def _call(lock, pause, n, g, item):\n",
@@ -184,8 +189,8 @@
184189
"outputs": [],
185190
"source": [
186191
"#export\n",
187-
"class ProcessPoolExecutor(concurrent.futures.ProcessPoolExecutor):\n",
188-
" \"Same as Python's ProcessPoolExecutor, except can pass `max_workers==0` for serial execution\"\n",
192+
"class ThreadPoolExecutor(concurrent.futures.ThreadPoolExecutor):\n",
193+
" \"Same as Python's ThreadPoolExecutor, except can pass `max_workers==0` for serial execution\"\n",
189194
" def __init__(self, max_workers=defaults.cpus, on_exc=print, pause=0, **kwargs):\n",
190195
" if max_workers is None: max_workers=defaults.cpus\n",
191196
" store_attr()\n",
@@ -202,15 +207,41 @@
202207
" except Exception as e: self.on_exc(e)"
203208
]
204209
},
210+
{
211+
"cell_type": "code",
212+
"execution_count": null,
213+
"metadata": {},
214+
"outputs": [
215+
{
216+
"data": {
217+
"text/markdown": [
218+
"<h4 id=\"ThreadPoolExecutor\" class=\"doc_header\"><code>class</code> <code>ThreadPoolExecutor</code><a href=\"\" class=\"source_link\" style=\"float:right\">[source]</a></h4>\n",
219+
"\n",
220+
"> <code>ThreadPoolExecutor</code>(**`max_workers`**=*`64`*, **`on_exc`**=*`print`*, **`pause`**=*`0`*, **\\*\\*`kwargs`**) :: [`ThreadPoolExecutor`](/parallel.html#ThreadPoolExecutor)\n",
221+
"\n",
222+
"Same as Python's ThreadPoolExecutor, except can pass `max_workers==0` for serial execution"
223+
],
224+
"text/plain": [
225+
"<IPython.core.display.Markdown object>"
226+
]
227+
},
228+
"metadata": {},
229+
"output_type": "display_data"
230+
}
231+
],
232+
"source": [
233+
"show_doc(ThreadPoolExecutor, title_level=4)"
234+
]
235+
},
205236
{
206237
"cell_type": "code",
207238
"execution_count": null,
208239
"metadata": {},
209240
"outputs": [],
210241
"source": [
211242
"#export\n",
212-
"class ThreadPoolExecutor(concurrent.futures.ThreadPoolExecutor):\n",
213-
" \"Same as Python's ThreadPoolExecutor, except can pass `max_workers==0` for serial execution\"\n",
243+
"class ProcessPoolExecutor(concurrent.futures.ProcessPoolExecutor):\n",
244+
" \"Same as Python's ProcessPoolExecutor, except can pass `max_workers==0` for serial execution\"\n",
214245
" def __init__(self, max_workers=defaults.cpus, on_exc=print, pause=0, **kwargs):\n",
215246
" if max_workers is None: max_workers=defaults.cpus\n",
216247
" store_attr()\n",
@@ -368,11 +399,11 @@
368399
"name": "stdout",
369400
"output_type": "stream",
370401
"text": [
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"
402+
"1 2020-12-11 19:32:27.930895\n",
403+
"0 2020-12-11 19:32:28.181040\n",
404+
"2 2020-12-11 19:32:28.431867\n",
405+
"3 2020-12-11 19:32:28.682935\n",
406+
"4 2020-12-11 19:32:28.933846\n"
376407
]
377408
}
378409
],

nbs/08_script.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@
375375
"def f(required:Param(\"Required param\", int),\n",
376376
" a:Param(\"param 1\", bool_arg),\n",
377377
" b:Param(\"param 2\", str)=\"test\",\n",
378-
" c:Param(\"param 3\", en)=_en.aa):\n",
378+
" c:Param(\"param 3\", _en)=_en.aa):\n",
379379
" \"my docs\"\n",
380380
" ...\n",
381381
"\n",

0 commit comments

Comments
 (0)