From 3e375edbd7f5f1f17b8ff82abdad90aabaddd374 Mon Sep 17 00:00:00 2001 From: AlexNg Date: Mon, 26 Feb 2024 21:31:45 +0800 Subject: [PATCH 1/2] fix: Update function signature to support multiple arguments --- src/thread/_types.py | 4 ++-- src/thread/thread.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/thread/_types.py b/src/thread/_types.py index 8040d78..6a50a1e 100644 --- a/src/thread/_types.py +++ b/src/thread/_types.py @@ -5,7 +5,7 @@ """ from typing import Any, Literal, Callable, Union -from typing_extensions import ParamSpec, TypeVar +from typing_extensions import ParamSpec, TypeVar, Concatenate # Descriptive Types @@ -34,4 +34,4 @@ HookFunction = Callable[[_Target_T], Union[Any, None]] _Dataset_T = TypeVar('_Dataset_T') -DatasetFunction = Callable[[_Dataset_T], _Target_T] +DatasetFunction = Callable[Concatenate[_Dataset_T, _Target_P], _Target_T] diff --git a/src/thread/thread.py b/src/thread/thread.py index a0017a6..6ca2269 100644 --- a/src/thread/thread.py +++ b/src/thread/thread.py @@ -346,7 +346,7 @@ class ParallelProcessing(Generic[_Target_P, _Target_T, _Dataset_T]): def __init__( self, - function: DatasetFunction[_Dataset_T, _Target_T], + function: DatasetFunction[_Dataset_T, _Target_P, _Target_T], dataset: Sequence[_Dataset_T], max_threads: int = 8, *overflow_args: Overflow_In, From 2cd065469c210b18534f5fafd15088a79793a9e0 Mon Sep 17 00:00:00 2001 From: AlexNg Date: Mon, 26 Feb 2024 21:33:01 +0800 Subject: [PATCH 2/2] fix: Remove unneeded print --- src/thread/thread.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/thread/thread.py b/src/thread/thread.py index 6ca2269..325374e 100644 --- a/src/thread/thread.py +++ b/src/thread/thread.py @@ -507,8 +507,6 @@ def start(self) -> None: i: v for i, v in self.overflow_kwargs.items() if i != 'name' and i != 'args' } - print(parsed_args, self.overflow_args) - for i, data_chunk in enumerate(chunk_split(self.dataset, max_threads)): chunk_thread = Thread( target=self.function,