raise an error when function is not pickleable and we are using the default executor.
Joseph Weston authored on 19/11/2019 21:27:16 • GitHub committed on 19/11/2019 21:27:16... | ... |
@@ -5,6 +5,7 @@ import asyncio |
5 | 5 |
import concurrent.futures as concurrent |
6 | 6 |
import inspect |
7 | 7 |
import os |
8 |
+import pickle |
|
8 | 9 |
import sys |
9 | 10 |
import time |
10 | 11 |
import traceback |
... | ... |
@@ -494,6 +495,18 @@ class AsyncRunner(BaseRunner): |
494 | 495 |
def goal(_): |
495 | 496 |
return False |
496 | 497 |
|
498 |
+ if executor is None and not inspect.iscoroutinefunction(learner.function): |
|
499 |
+ try: |
|
500 |
+ pickle.dumps(learner.function) |
|
501 |
+ except pickle.PicklingError: |
|
502 |
+ raise ValueError( |
|
503 |
+ "`learner.function` cannot be pickled (is it a lamdba function?)" |
|
504 |
+ " and therefore does not work with the default executor." |
|
505 |
+ " Either make sure the function is pickleble or use an executor" |
|
506 |
+ " that might work with 'hard to pickle'-functions" |
|
507 |
+ " , e.g. `ipyparallel` with `dill`." |
|
508 |
+ ) |
|
509 |
+ |
|
497 | 510 |
super().__init__( |
498 | 511 |
learner, |
499 | 512 |
goal, |