Skip to content

Commit 199f2a1

Browse files
committed
introduce _FutureTypes
1 parent b69dc76 commit 199f2a1

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

adaptive/runner.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
_ThirdPartyClient = []
2222
_ThirdPartyExecutor = [loky.reusable_executor._ReusablePoolExecutor]
23+
_FutureTypes = [Set[Future], Set[Task]]
2324

2425
try:
2526
import ipyparallel
@@ -28,6 +29,7 @@
2829
with_ipyparallel = True
2930
_ThirdPartyClient.append(ipyparallel.Client)
3031
_ThirdPartyExecutor.append(ipyparallel.client.view.ViewExecutor)
32+
_FutureTypes.append(AsyncResult)
3133
except ModuleNotFoundError:
3234
with_ipyparallel = False
3335

@@ -306,11 +308,7 @@ def overhead(self):
306308

307309
def _process_futures(
308310
self,
309-
done_futs: Union[
310-
Set[Future],
311-
Set[AsyncResult], # XXX: AsyncResult might not be imported
312-
Set[Task],
313-
],
311+
done_futs: Union[(*_FutureTypes,)],
314312
) -> None:
315313
for fut in done_futs:
316314
pid = self._pending_tasks.pop(fut)
@@ -335,11 +333,7 @@ def _process_futures(
335333

336334
def _get_futures(
337335
self,
338-
) -> Union[
339-
List[Task],
340-
List[Future],
341-
List[AsyncResult], # XXX: AsyncResult might not be imported
342-
]:
336+
) -> Union[(*_FutureTypes,)]:
343337
# Launch tasks to replace the ones that completed
344338
# on the last iteration, making sure to fill workers
345339
# that have started since the last iteration.

0 commit comments

Comments
 (0)