Skip to content

Commit d193ec5

Browse files
committed
raise an error when using a lambda and default executor
Closes #206.
1 parent 6794a06 commit d193ec5

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

adaptive/runner.py

+9
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import sys
99
import time
1010
import traceback
11+
import types
1112
import warnings
1213
from contextlib import suppress
1314

@@ -494,6 +495,14 @@ def __init__(
494495
def goal(_):
495496
return False
496497

498+
if isinstance(learner.function, types.LambdaType) and executor is None:
499+
raise ValueError(
500+
"A lambda function cannot be pickled and "
501+
"therefore doesn't work with the default executor."
502+
"Either do not use a lamdba or use a framework that"
503+
" allows this, i.e. `ipyparallel` with `dill`."
504+
)
505+
497506
super().__init__(
498507
learner,
499508
goal,

0 commit comments

Comments
 (0)