2
2
import asyncio
3
3
import concurrent .futures as concurrent
4
4
import inspect
5
- import os
6
5
import pickle
7
6
import sys
8
7
import time
39
38
asyncio .set_event_loop_policy (uvloop .EventLoopPolicy ())
40
39
41
40
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
-
66
41
class BaseRunner (metaclass = abc .ABCMeta ):
67
42
r"""Base class for runners that use `concurrent.futures.Executors`.
68
43
@@ -76,9 +51,7 @@ class BaseRunner(metaclass=abc.ABCMeta):
76
51
executor : `concurrent.futures.Executor`, `distributed.Client`,\
77
52
`mpi4py.futures.MPIPoolExecutor`, or `ipyparallel.Client`, optional
78
53
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`.
82
55
ntasks : int, optional
83
56
The number of concurrent function evaluations. Defaults to the number
84
57
of cores available in `executor`.
@@ -298,9 +271,7 @@ class BlockingRunner(BaseRunner):
298
271
executor : `concurrent.futures.Executor`, `distributed.Client`,\
299
272
`mpi4py.futures.MPIPoolExecutor`, or `ipyparallel.Client`, optional
300
273
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`.
304
275
ntasks : int, optional
305
276
The number of concurrent function evaluations. Defaults to the number
306
277
of cores available in `executor`.
@@ -417,9 +388,7 @@ class AsyncRunner(BaseRunner):
417
388
executor : `concurrent.futures.Executor`, `distributed.Client`,\
418
389
`mpi4py.futures.MPIPoolExecutor`, or `ipyparallel.Client`, optional
419
390
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`.
423
392
ntasks : int, optional
424
393
The number of concurrent function evaluations. Defaults to the number
425
394
of cores available in `executor`.
@@ -773,7 +742,7 @@ def shutdown(self, wait=True):
773
742
774
743
def _ensure_executor (executor ):
775
744
if executor is None :
776
- executor = _default_executor ( ** _default_executor_kwargs )
745
+ executor = concurrent . ProcessPoolExecutor ( )
777
746
778
747
if isinstance (executor , concurrent .Executor ):
779
748
return executor
0 commit comments