Skip to content

Commit

Permalink
fix test_default_executor
Browse files Browse the repository at this point in the history
  • Loading branch information
basnijholt committed Apr 10, 2020
1 parent 649889f commit 0f85d3a
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions adaptive/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@
asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())


_default_executor = (
loky.get_reusable_executor if with_loky else concurrent.ProcessPoolExecutor
)


class BaseRunner(metaclass=abc.ABCMeta):
r"""Base class for runners that use `concurrent.futures.Executors`.
Expand Down Expand Up @@ -478,7 +483,11 @@ def __init__(
def goal(_):
return False

if executor is None and not inspect.iscoroutinefunction(learner.function):
if (
executor is None
and _default_executor is concurrent.ProcessPoolExecutor
and not inspect.iscoroutinefunction(learner.function)
):
try:
pickle.dumps(learner.function)
except pickle.PicklingError:
Expand Down Expand Up @@ -756,13 +765,6 @@ def shutdown(self, wait=True):
pass


def _default_executor():
if with_loky:
return loky.get_reusable_executor()
else:
return concurrent.ProcessPoolExecutor()


def _ensure_executor(executor):
if executor is None:
executor = _default_executor()
Expand Down

0 comments on commit 0f85d3a

Please sign in to comment.