From 519a1669302a1ee6a8416cd3811b25028ad1dd15 Mon Sep 17 00:00:00 2001 From: Philipenko Vladimir Date: Thu, 28 Dec 2023 15:39:15 +0300 Subject: [PATCH] Simplify --- dpipe/itertools.py | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/dpipe/itertools.py b/dpipe/itertools.py index 3e56455..5edd35d 100644 --- a/dpipe/itertools.py +++ b/dpipe/itertools.py @@ -113,10 +113,6 @@ def pmap(func: Callable, iterable: Iterable, *args, **kwargs) -> Iterable: yield func(value, *args, **kwargs) -class FinishToken: - pass - - class AsyncPmap: def __init__(self, func: Callable, iterable: Iterable, *args, **kwargs) -> None: self.__func = func @@ -143,7 +139,7 @@ def _prediction_func(self) -> None: try: for value in self.__iterable: self.__result_queue.put((self.__func(value, *self.__args, **self.__kwargs), True)) - self.__result_queue.put((FinishToken, True)) + raise StopIteration except BaseException as e: self.__result_queue.put((e, False)) @@ -161,10 +157,6 @@ def __next__(self) -> Any: self.stop() raise obj - if obj is FinishToken: - self.stop() - raise StopIteration - return obj