diff --git a/adaptive/runner.py b/adaptive/runner.py index 6fdef7e577e3b2cab633b65b93b52d54931c4c8c..12455f67736c34968e82429f413bd2ad1141236a 100644 --- a/adaptive/runner.py +++ b/adaptive/runner.py @@ -84,10 +84,11 @@ class _AsyncExecutor: def _ensure_async_executor(executor, ioloop): - if isinstance(executor, concurrent.Executor): - pass - elif isinstance(executor, ipyparallel.Client): + if isinstance(executor, ipyparallel.Client): executor = executor.executor() + elif isinstance(executor, (concurrent.ProcessPoolExecutor, + concurrent.ThreadPoolExecutor)): + pass elif executor is None: executor = concurrent.ProcessPoolExecutor() else: @@ -102,10 +103,11 @@ def _get_executor_ncores(executor): if isinstance(executor, _AsyncExecutor): executor = executor.executor - if isinstance(executor, concurrent.Executor): + if isinstance(executor, ipyparallel.client.view.ViewExecutor): + return len(executor.view) + elif isinstance(executor, (concurrent.ProcessPoolExecutor, + concurrent.ThreadPoolExecutor)): return executor._max_workers # not public API! - elif isinstance(executor, ipyparallel.Client): - return len(executor) else: raise TypeError('Only concurrent.futures.Executors or ipyparallel ' 'clients can be used.')