Skip to content

Commit 36eb11b

Browse files
committed
[Feature] Compare future results based on id
1 parent 49fca86 commit 36eb11b

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

src/executorlib/standalone/batched.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from concurrent.futures import Future
2+
from unittest import result
23

34

45
def batched_futures(lst: list[Future], skip_lst: list[list], n: int) -> list[list]:
@@ -15,13 +16,13 @@ def batched_futures(lst: list[Future], skip_lst: list[list], n: int) -> list[lis
1516
Returns:
1617
list: results of the batched futures
1718
"""
18-
skipped_elements_lst = [item for items in skip_lst for item in items]
19+
skipped_ids = {id(item) for items in skip_lst for item in items}
1920

2021
done_lst = []
21-
n_expected = min(n, len(lst) - len(skipped_elements_lst))
22+
n_expected = min(n, len(lst) - len(skipped_ids))
2223
for v in lst:
23-
if v.done() and v.result() not in skipped_elements_lst:
24+
if v.done() and id(v.result()) not in skipped_ids:
2425
done_lst.append(v.result())
25-
if len(done_lst) == n_expected:
26-
return done_lst
26+
if len(done_lst) == n_expected:
27+
return done_lst
2728
return []

0 commit comments

Comments
 (0)