Skip to content

Commit c037c78

Browse files
authored
Fix python 3.10 issue (#583)
1 parent 8dc0584 commit c037c78

File tree

2 files changed

+10
-36
lines changed

2 files changed

+10
-36
lines changed

executorlib/interactive/shared.py

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import sys
55
import time
66
from asyncio.exceptions import CancelledError
7-
from concurrent.futures import Future
7+
from concurrent.futures import Future, TimeoutError
88
from time import sleep
99
from typing import Any, Callable, Optional, Union
1010

@@ -672,15 +672,13 @@ def _execute_task_with_cache(
672672
future_queue.task_done()
673673

674674

675-
def _get_exception_lst(future_lst: list) -> list:
676-
def get_exception(future_obj: Future) -> bool:
677-
try:
678-
excp = future_obj.exception(timeout=10**-10)
679-
return excp is not None and not isinstance(excp, CancelledError)
680-
except TimeoutError:
681-
return False
675+
def _get_exception_lst(future_lst: list[Future]) -> list:
676+
return [f.exception() for f in future_lst if _get_exception(future_obj=f)]
682677

683-
if sys.version_info[0] >= 3 and sys.version_info[1] >= 11:
684-
return [f.exception() for f in future_lst if get_exception(future_obj=f)]
685-
else:
686-
return []
678+
679+
def _get_exception(future_obj: Future) -> bool:
680+
try:
681+
excp = future_obj.exception(timeout=10**-10)
682+
return excp is not None and not isinstance(excp, CancelledError)
683+
except TimeoutError:
684+
return False

tests/test_dependencies_executor.py

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,6 @@ def test_dependency_steps(self):
107107
self.assertTrue(fs2.done())
108108
q.put({"shutdown": True, "wait": True})
109109

110-
@unittest.skipIf(
111-
condition=not (sys.version_info[0] >= 3 and sys.version_info[1] >= 11),
112-
reason="requires Python 3.11 or higher",
113-
)
114110
def test_dependency_steps_error(self):
115111
cloudpickle_register(ind=1)
116112
fs1 = Future()
@@ -164,10 +160,6 @@ def test_dependency_steps_error(self):
164160
fs2.result()
165161
q.put({"shutdown": True, "wait": True})
166162

167-
@unittest.skipIf(
168-
condition=not (sys.version_info[0] >= 3 and sys.version_info[1] >= 11),
169-
reason="requires Python 3.11 or higher",
170-
)
171163
def test_dependency_steps_error_before(self):
172164
cloudpickle_register(ind=1)
173165
fs1 = Future()
@@ -282,10 +274,6 @@ def test_block_allocation_true_two_workers(self):
282274
cloudpickle_register(ind=1)
283275
_ = exe.submit(raise_error, parameter=0)
284276

285-
@unittest.skipIf(
286-
condition=not (sys.version_info[0] >= 3 and sys.version_info[1] >= 11),
287-
reason="requires Python 3.11 or higher",
288-
)
289277
def test_block_allocation_false_one_worker_loop(self):
290278
with self.assertRaises(RuntimeError):
291279
with SingleNodeExecutor(max_cores=1, block_allocation=False) as exe:
@@ -298,10 +286,6 @@ def test_block_allocation_false_one_worker_loop(self):
298286
)
299287
lst.result()
300288

301-
@unittest.skipIf(
302-
condition=not (sys.version_info[0] >= 3 and sys.version_info[1] >= 11),
303-
reason="requires Python 3.11 or higher",
304-
)
305289
def test_block_allocation_true_one_worker_loop(self):
306290
with self.assertRaises(RuntimeError):
307291
with SingleNodeExecutor(max_cores=1, block_allocation=True) as exe:
@@ -314,10 +298,6 @@ def test_block_allocation_true_one_worker_loop(self):
314298
)
315299
lst.result()
316300

317-
@unittest.skipIf(
318-
condition=not (sys.version_info[0] >= 3 and sys.version_info[1] >= 11),
319-
reason="requires Python 3.11 or higher",
320-
)
321301
def test_block_allocation_false_two_workers_loop(self):
322302
with self.assertRaises(RuntimeError):
323303
with SingleNodeExecutor(max_cores=2, block_allocation=False) as exe:
@@ -330,10 +310,6 @@ def test_block_allocation_false_two_workers_loop(self):
330310
)
331311
lst.result()
332312

333-
@unittest.skipIf(
334-
condition=not (sys.version_info[0] >= 3 and sys.version_info[1] >= 11),
335-
reason="requires Python 3.11 or higher",
336-
)
337313
def test_block_allocation_true_two_workers_loop(self):
338314
with self.assertRaises(RuntimeError):
339315
with SingleNodeExecutor(max_cores=2, block_allocation=True) as exe:

0 commit comments

Comments
 (0)