Skip to content

Commit 65d703f

Browse files
committed
fix import
1 parent cd5a2ac commit 65d703f

File tree

2 files changed

+33
-61
lines changed

2 files changed

+33
-61
lines changed

fastcore/parallel.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,19 @@
55
'run_procs', 'parallel_gen']
66

77
# %% ../nbs/03a_parallel.ipynb 1
8-
from .utils import *
8+
from .imports import *
9+
from .basics import *
10+
from .foundation import *
911
from .meta import *
1012
from .xtras import *
1113
from functools import wraps
1214

1315
import concurrent.futures,time
1416
from multiprocessing import Process,Queue,Manager,set_start_method,get_all_start_methods,get_context
1517
from threading import Thread
18+
try:
19+
if sys.platform == 'darwin' and IN_NOTEBOOK: set_start_method("fork")
20+
except: pass
1621

1722
# %% ../nbs/03a_parallel.ipynb 4
1823
def threaded(f):

nbs/03a_parallel.ipynb

Lines changed: 27 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,24 @@
1111
},
1212
{
1313
"cell_type": "code",
14-
"execution_count": 41,
14+
"execution_count": 2,
1515
"metadata": {},
1616
"outputs": [],
1717
"source": [
1818
"#|export\n",
19-
"from fastcore.utils import *\n",
19+
"from fastcore.imports import *\n",
20+
"from fastcore.basics import *\n",
21+
"from fastcore.foundation import *\n",
2022
"from fastcore.meta import *\n",
2123
"from fastcore.xtras import *\n",
2224
"from functools import wraps\n",
2325
"\n",
2426
"import concurrent.futures,time\n",
2527
"from multiprocessing import Process,Queue,Manager,set_start_method,get_all_start_methods,get_context\n",
26-
"from threading import Thread"
28+
"from threading import Thread\n",
29+
"try:\n",
30+
" if sys.platform == 'darwin' and IN_NOTEBOOK: set_start_method(\"fork\")\n",
31+
"except: pass"
2732
]
2833
},
2934
{
@@ -210,7 +215,7 @@
210215
"Same as Python's ThreadPoolExecutor, except can pass `max_workers==0` for serial execution"
211216
],
212217
"text/plain": [
213-
"<nbdev.showdoc.BasicMarkdownRenderer at 0x111d8beb0>"
218+
"<nbdev.showdoc.BasicMarkdownRenderer at 0x1034390a0>"
214219
]
215220
},
216221
"execution_count": 11,
@@ -224,7 +229,7 @@
224229
},
225230
{
226231
"cell_type": "code",
227-
"execution_count": 44,
232+
"execution_count": 12,
228233
"metadata": {},
229234
"outputs": [],
230235
"source": [
@@ -254,7 +259,7 @@
254259
},
255260
{
256261
"cell_type": "code",
257-
"execution_count": 45,
262+
"execution_count": 13,
258263
"metadata": {},
259264
"outputs": [
260265
{
@@ -271,10 +276,10 @@
271276
"Same as Python's ProcessPoolExecutor, except can pass `max_workers==0` for serial execution"
272277
],
273278
"text/plain": [
274-
"<nbdev.showdoc.BasicMarkdownRenderer at 0x130453370>"
279+
"<nbdev.showdoc.BasicMarkdownRenderer at 0x10f325e20>"
275280
]
276281
},
277-
"execution_count": 45,
282+
"execution_count": 13,
278283
"metadata": {},
279284
"output_type": "execute_result"
280285
}
@@ -285,7 +290,7 @@
285290
},
286291
{
287292
"cell_type": "code",
288-
"execution_count": 46,
293+
"execution_count": 14,
289294
"metadata": {},
290295
"outputs": [],
291296
"source": [
@@ -296,7 +301,7 @@
296301
},
297302
{
298303
"cell_type": "code",
299-
"execution_count": 52,
304+
"execution_count": 15,
300305
"metadata": {},
301306
"outputs": [],
302307
"source": [
@@ -320,7 +325,7 @@
320325
},
321326
{
322327
"cell_type": "code",
323-
"execution_count": 48,
328+
"execution_count": 16,
324329
"metadata": {},
325330
"outputs": [],
326331
"source": [
@@ -334,7 +339,7 @@
334339
},
335340
{
336341
"cell_type": "code",
337-
"execution_count": 50,
342+
"execution_count": 17,
338343
"metadata": {},
339344
"outputs": [],
340345
"source": [
@@ -364,11 +369,11 @@
364369
"name": "stdout",
365370
"output_type": "stream",
366371
"text": [
367-
"0 2022-07-26 03:53:34.945994\n",
368-
"1 2022-07-26 03:53:35.197160\n",
369-
"2 2022-07-26 03:53:35.449657\n",
370-
"3 2022-07-26 03:53:35.700623\n",
371-
"4 2022-07-26 03:53:35.952134\n"
372+
"0 2022-07-26 04:12:18.858918\n",
373+
"1 2022-07-26 04:12:19.110316\n",
374+
"2 2022-07-26 04:12:19.362060\n",
375+
"3 2022-07-26 04:12:19.612606\n",
376+
"4 2022-07-26 04:12:19.863821\n"
372377
]
373378
}
374379
],
@@ -384,7 +389,7 @@
384389
},
385390
{
386391
"cell_type": "code",
387-
"execution_count": 29,
392+
"execution_count": 19,
388393
"metadata": {},
389394
"outputs": [],
390395
"source": [
@@ -395,7 +400,7 @@
395400
},
396401
{
397402
"cell_type": "code",
398-
"execution_count": 30,
403+
"execution_count": 20,
399404
"metadata": {},
400405
"outputs": [
401406
{
@@ -404,7 +409,7 @@
404409
"(#8) [0,2,4,6,8,10,12,14]"
405410
]
406411
},
407-
"execution_count": 30,
412+
"execution_count": 20,
408413
"metadata": {},
409414
"output_type": "execute_result"
410415
}
@@ -467,45 +472,7 @@
467472
"cell_type": "code",
468473
"execution_count": 24,
469474
"metadata": {},
470-
"outputs": [
471-
{
472-
"data": {
473-
"text/html": [
474-
"\n",
475-
"<style>\n",
476-
" /* Turns off some styling */\n",
477-
" progress {\n",
478-
" /* gets rid of default border in Firefox and Opera. */\n",
479-
" border: none;\n",
480-
" /* Needs to be in here for Safari polyfill so background images work as expected. */\n",
481-
" background-size: auto;\n",
482-
" }\n",
483-
" progress:not([value]), progress:not([value])::-webkit-progress-bar {\n",
484-
" background: repeating-linear-gradient(45deg, #7e7e7e, #7e7e7e 10px, #5c5c5c 10px, #5c5c5c 20px);\n",
485-
" }\n",
486-
" .progress-bar-interrupted, .progress-bar-interrupted::-webkit-progress-bar {\n",
487-
" background: #F44336;\n",
488-
" }\n",
489-
"</style>\n"
490-
],
491-
"text/plain": [
492-
"<IPython.core.display.HTML object>"
493-
]
494-
},
495-
"metadata": {},
496-
"output_type": "display_data"
497-
},
498-
{
499-
"data": {
500-
"text/html": [],
501-
"text/plain": [
502-
"<IPython.core.display.HTML object>"
503-
]
504-
},
505-
"metadata": {},
506-
"output_type": "display_data"
507-
}
508-
],
475+
"outputs": [],
509476
"source": [
510477
"# class _C:\n",
511478
"# def __call__(self, o): return ((i+1) for i in o)\n",
@@ -610,7 +577,7 @@
610577
},
611578
{
612579
"cell_type": "code",
613-
"execution_count": 53,
580+
"execution_count": 27,
614581
"metadata": {},
615582
"outputs": [],
616583
"source": [

0 commit comments

Comments
 (0)