|
26 | 26 | from nbconvert.filters import strip_ansi
|
27 | 27 | from testpath import modified_env
|
28 | 28 | from ipython_genutils.py3compat import string_types
|
29 |
| -from pebble import ProcessPool |
| 29 | +import concurrent.futures |
30 | 30 |
|
31 | 31 | from queue import Empty
|
32 | 32 | from unittest.mock import MagicMock, Mock
|
@@ -82,6 +82,12 @@ def run_notebook(filename, opts, resources=None):
|
82 | 82 | return input_nb, output_nb
|
83 | 83 |
|
84 | 84 |
|
| 85 | +def run_notebook_wrapper(args): |
| 86 | + # since concurrent.futures.ProcessPoolExecutor doesn't have starmap, |
| 87 | + # we need to unpack the arguments |
| 88 | + return run_notebook(*args) |
| 89 | + |
| 90 | + |
85 | 91 | async def async_run_notebook(filename, opts, resources=None):
|
86 | 92 | """Loads and runs a notebook, returning both the version prior to
|
87 | 93 | running it and the version after running it.
|
@@ -301,13 +307,8 @@ def test_many_parallel_notebooks(capfd):
|
301 | 307 | # run once, to trigger creating the original context
|
302 | 308 | run_notebook(input_file, opts, res)
|
303 | 309 |
|
304 |
| - with ProcessPool(max_workers=2) as pool: |
305 |
| - futures = [ |
306 |
| - pool.schedule(run_notebook, args=(input_file, opts, res)) |
307 |
| - for i in range(8) |
308 |
| - ] |
309 |
| - for index, future in enumerate(futures): |
310 |
| - future.result() |
| 310 | + with concurrent.futures.ProcessPoolExecutor(max_workers=2) as executor: |
| 311 | + executor.map(run_notebook_wrapper, [(input_file, opts, res) for i in range(8)]) |
311 | 312 |
|
312 | 313 | captured = capfd.readouterr()
|
313 | 314 | assert captured.err == ""
|
|
0 commit comments