Skip to content

Commit

Permalink
Simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
vovaf709 committed Dec 28, 2023
1 parent 210c8f9 commit 519a166
Showing 1 changed file with 1 addition and 9 deletions.
10 changes: 1 addition & 9 deletions dpipe/itertools.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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))

Expand All @@ -161,10 +157,6 @@ def __next__(self) -> Any:
self.stop()
raise obj

if obj is FinishToken:
self.stop()
raise StopIteration

return obj


Expand Down

0 comments on commit 519a166

Please sign in to comment.