Skip to content

Commit f6e52d8

Browse files
stellaraccidentGroverkss
authored andcommitted
[python] Make detection of TimeoutError compatible with 3.10. (iree-org#19308)
* In python < 3.11, future methods throw concurrent.futures.TimeoutError. * In python 3.11, concurrent.futures.TimeoutError is a subclass of TimeoutError and the former is deprecated. * In python 3.10, TimeoutError exists so can have an except clause, but it is not thrown by futures. --------- Signed-off-by: Stella Laurenzo <[email protected]>
1 parent abd6119 commit f6e52d8

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

compiler/bindings/python/iree/build/executor.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,12 @@ def _service_graph(self):
519519
completed_deps.add(completed_dep)
520520
except TimeoutError:
521521
pass
522+
except concurrent.futures.TimeoutError:
523+
# In Python 3.10, future access throws concurrent.futures.TimeoutError.
524+
# In 3.11, that was made a subclass of TimeoutError, which is advertised
525+
# as thrown (and the original is marked as deprecated).
526+
# TODO: Remove this clause once 3.10 support is dropped.
527+
pass
522528

523529
# Purge done from in-flight list.
524530
self.in_flight_deps.difference_update(completed_deps)

compiler/bindings/python/test/build_api/CMakeLists.txt

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,9 @@ if(IREE_INPUT_TORCH)
1414
)
1515
endif()
1616

17-
# FIXME: This test fails on python3.10.
18-
# iree_py_test(
19-
# NAME
20-
# concurrency_test
21-
# SRCS
22-
# "concurrency_test.py"
23-
#)
17+
iree_py_test(
18+
NAME
19+
concurrency_test
20+
SRCS
21+
"concurrency_test.py"
22+
)

0 commit comments

Comments
 (0)