Skip to content

Commit 60be696

Browse files
committed
handle case where Windows user tries to use default executor
Previously a NameError would be raised because '_default_executor' was not defined in the case that the user is on windows and distributed is not installed. Now the user will get a RuntimeError with an informative error message if they try and instantiate a runner with the default executor.
1 parent d8cdebc commit 60be696

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

adaptive/runner.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,20 @@
3333
_default_executor = distributed.Client
3434
_default_executor_kwargs = {'address': distributed.LocalCluster()}
3535
else:
36-
warnings.warn(
36+
_windows_executor_msg = (
3737
"The default executor on Windows for 'adaptive.Runner' cannot "
3838
"be used because the package 'distributed' is not installed. "
3939
"Either install 'distributed' or explicitly specify an executor "
4040
"when using 'adaptive.Runner'."
4141
)
42+
43+
_default_executor_kwargs = {}
44+
45+
def _default_executor(*args, **kwargs):
46+
raise RuntimeError(_windows_executor_msg)
47+
48+
warnings.warn(_windows_executor_msg)
49+
4250
else:
4351
_default_executor = concurrent.ProcessPoolExecutor
4452
_default_executor_kwargs = {}

0 commit comments

Comments
 (0)