Skip to content

Commit 0f85d3a

Browse files
committed
fix test_default_executor
1 parent 649889f commit 0f85d3a

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

adaptive/runner.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@
4949
asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())
5050

5151

52+
_default_executor = (
53+
loky.get_reusable_executor if with_loky else concurrent.ProcessPoolExecutor
54+
)
55+
56+
5257
class BaseRunner(metaclass=abc.ABCMeta):
5358
r"""Base class for runners that use `concurrent.futures.Executors`.
5459
@@ -478,7 +483,11 @@ def __init__(
478483
def goal(_):
479484
return False
480485

481-
if executor is None and not inspect.iscoroutinefunction(learner.function):
486+
if (
487+
executor is None
488+
and _default_executor is concurrent.ProcessPoolExecutor
489+
and not inspect.iscoroutinefunction(learner.function)
490+
):
482491
try:
483492
pickle.dumps(learner.function)
484493
except pickle.PicklingError:
@@ -756,13 +765,6 @@ def shutdown(self, wait=True):
756765
pass
757766

758767

759-
def _default_executor():
760-
if with_loky:
761-
return loky.get_reusable_executor()
762-
else:
763-
return concurrent.ProcessPoolExecutor()
764-
765-
766768
def _ensure_executor(executor):
767769
if executor is None:
768770
executor = _default_executor()

0 commit comments

Comments
 (0)