File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 55import concurrent .futures as concurrent
66import inspect
77import os
8+ import pickle
89import sys
910import time
1011import traceback
@@ -495,13 +496,18 @@ def __init__(
495496 def goal (_ ):
496497 return False
497498
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- )
499+ if executor is None :
500+ if isinstance (learner .function , types .LambdaType ):
501+ raise ValueError (
502+ "A lambda function cannot be pickled and "
503+ "therefore doesn't work with the default executor."
504+ "Either do not use a lamdba or use a framework that"
505+ " allows this, e.g. `ipyparallel` with `dill`."
506+ )
507+ try :
508+ pickle .dumps (learner .function )
509+ except pickle .PicklingError :
510+ raise ValueError ("`learner.function` needs to be pickleble." )
505511
506512 super ().__init__ (
507513 learner ,
You can’t perform that action at this time.
0 commit comments