Skip to content

Commit 0058979

Browse files
Copilotakhmerov
andcommitted
Fix Python 3.14 test failures: check hasattr and reorder isinstance checks
Co-authored-by: akhmerov <[email protected]>
1 parent 522babc commit 0058979

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

adaptive/runner.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@
4545

4646

4747
# -- Runner definitions
48-
_has_interpreter_pool = sys.version_info >= (3, 14)
48+
_has_interpreter_pool = sys.version_info >= (3, 14) and hasattr(
49+
concurrent, "InterpreterPoolExecutor"
50+
)
4951

5052
if _has_interpreter_pool:
5153
_default_executor = concurrent.InterpreterPoolExecutor # type: ignore[misc,attr-defined]
@@ -1034,10 +1036,10 @@ def _get_ncores(
10341036
import mpi4py.futures
10351037
if with_ipyparallel and isinstance(ex, ipyparallel.client.view.ViewExecutor):
10361038
return len(ex.view)
1037-
elif isinstance(ex, concurrent.ProcessPoolExecutor | concurrent.ThreadPoolExecutor):
1038-
return ex._max_workers # type: ignore[union-attr]
10391039
elif _has_interpreter_pool and isinstance(ex, concurrent.InterpreterPoolExecutor): # type: ignore[attr-defined]
10401040
return ex._max_workers # type: ignore[union-attr]
1041+
elif isinstance(ex, concurrent.ProcessPoolExecutor | concurrent.ThreadPoolExecutor):
1042+
return ex._max_workers # type: ignore[union-attr]
10411043
elif isinstance(ex, loky.reusable_executor._ReusablePoolExecutor):
10421044
return ex._max_workers # type: ignore[union-attr]
10431045
elif isinstance(ex, SequentialExecutor):

0 commit comments

Comments
 (0)