22import asyncio
33import concurrent .futures as concurrent
44import inspect
5- import os
65import pickle
76import sys
87import time
3938 asyncio .set_event_loop_policy (uvloop .EventLoopPolicy ())
4039
4140
42- if os .name == "nt" :
43- if with_distributed :
44- _default_executor = distributed .Client
45- _default_executor_kwargs = {"address" : distributed .LocalCluster ()}
46- else :
47- _windows_executor_msg = (
48- "The default executor on Windows for 'adaptive.Runner' cannot "
49- "be used because the package 'distributed' is not installed. "
50- "Either install 'distributed' or explicitly specify an executor "
51- "when using 'adaptive.Runner'."
52- )
53-
54- _default_executor_kwargs = {}
55-
56- def _default_executor (* args , ** kwargs ):
57- raise RuntimeError (_windows_executor_msg )
58-
59- warnings .warn (_windows_executor_msg )
60-
61- else :
62- _default_executor = concurrent .ProcessPoolExecutor
63- _default_executor_kwargs = {}
64-
65-
6641class BaseRunner (metaclass = abc .ABCMeta ):
6742 r"""Base class for runners that use `concurrent.futures.Executors`.
6843
@@ -76,9 +51,7 @@ class BaseRunner(metaclass=abc.ABCMeta):
7651 executor : `concurrent.futures.Executor`, `distributed.Client`,\
7752 `mpi4py.futures.MPIPoolExecutor`, or `ipyparallel.Client`, optional
7853 The executor in which to evaluate the function to be learned.
79- If not provided, a new `~concurrent.futures.ProcessPoolExecutor`
80- is used on Unix systems while on Windows a `distributed.Client`
81- is used if `distributed` is installed.
54+ If not provided, a new `~concurrent.futures.ProcessPoolExecutor`.
8255 ntasks : int, optional
8356 The number of concurrent function evaluations. Defaults to the number
8457 of cores available in `executor`.
@@ -298,9 +271,7 @@ class BlockingRunner(BaseRunner):
298271 executor : `concurrent.futures.Executor`, `distributed.Client`,\
299272 `mpi4py.futures.MPIPoolExecutor`, or `ipyparallel.Client`, optional
300273 The executor in which to evaluate the function to be learned.
301- If not provided, a new `~concurrent.futures.ProcessPoolExecutor`
302- is used on Unix systems while on Windows a `distributed.Client`
303- is used if `distributed` is installed.
274+ If not provided, a new `~concurrent.futures.ProcessPoolExecutor`.
304275 ntasks : int, optional
305276 The number of concurrent function evaluations. Defaults to the number
306277 of cores available in `executor`.
@@ -417,9 +388,7 @@ class AsyncRunner(BaseRunner):
417388 executor : `concurrent.futures.Executor`, `distributed.Client`,\
418389 `mpi4py.futures.MPIPoolExecutor`, or `ipyparallel.Client`, optional
419390 The executor in which to evaluate the function to be learned.
420- If not provided, a new `~concurrent.futures.ProcessPoolExecutor`
421- is used on Unix systems while on Windows a `distributed.Client`
422- is used if `distributed` is installed.
391+ If not provided, a new `~concurrent.futures.ProcessPoolExecutor`.
423392 ntasks : int, optional
424393 The number of concurrent function evaluations. Defaults to the number
425394 of cores available in `executor`.
@@ -773,7 +742,7 @@ def shutdown(self, wait=True):
773742
774743def _ensure_executor (executor ):
775744 if executor is None :
776- executor = _default_executor ( ** _default_executor_kwargs )
745+ executor = concurrent . ProcessPoolExecutor ( )
777746
778747 if isinstance (executor , concurrent .Executor ):
779748 return executor
0 commit comments