Skip to content

Commit 9217bbc

Browse files
Merge pull request #76 from python-thread/feature/v2.0.0
v2.0.0 Signed-off-by: AlexNg <contact@ngjx.org>
2 parents 8f1ad08 + 5750f33 commit 9217bbc

File tree

12 files changed

+104
-98
lines changed

12 files changed

+104
-98
lines changed

CITATION.cff

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ identifiers:
99
value: 10.5281/zenodo.10799219
1010
description: This is the collection of archived snapshots of all versions of thread.
1111
- type: url
12-
value: https://github.com/python-thread/thread/releases/tag/v1.1.1
13-
description: The GitHub release URL of tag v1.1.1.
12+
value: https://github.com/python-thread/thread/releases/tag/v2.0.0
13+
description: The GitHub release URL of tag v2.0.0.
1414
- type: url
15-
value: https://pypi.org/project/thread/1.1.1
16-
description: The PyPI release URL of tag v1.1.1.
15+
value: https://pypi.org/project/thread/2.0.0
16+
description: The PyPI release URL of tag v2.0.0.
1717
cff-version: 1.2.0
1818
date-released: 2024-03-07
1919
keywords:
@@ -32,6 +32,6 @@ repository-code: https://github.com/python-thread/thread
3232
repository-artifact: https://pypi.org/project/thread
3333
title: thread
3434
type: software
35-
version: 1.1.1
35+
version: 2.0.0
3636
url: https://thread.ngjx.org
3737

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ _Below is an example of how you can install and use thread._
7979
2. Import thread into your library!
8080
```py
8181
import thread
82-
from thread import Thread, ParallelProcessing
82+
from thread import Thread, ConcurrentProcessing
8383
```
8484

8585
<p align="right">(<a href="#readme-top">back to top</a>)</p>
@@ -98,7 +98,7 @@ Our docs are [here!](https://thread.ngjx.org)
9898
<!-- ROADMAP -->
9999
## Roadmap
100100

101-
- [x] v1.1.1 Release
101+
- [x] v2.0.0 Release
102102
- [ ] Bug fixes
103103
- [ ] New features
104104
- [ ] Testing

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "thread"
3-
version = "1.1.1"
3+
version = "2.0.0"
44
description = "Threading module extension"
55
authors = ["Alex <contact@ngjx.org>"]
66
license = "BSD-3-Clause"
@@ -30,7 +30,7 @@ classifiers = [
3030

3131
[tool.poetry.urls]
3232
Homepage = "https://thread.ngjx.org"
33-
Documentation = "https://thread.ngjx.org/docs/v1.1.1"
33+
Documentation = "https://thread.ngjx.org/docs/v2.0.0"
3434
Source = "https://github.com/python-thread/thread"
3535
Download = "https://pypi.org/project/thread/#files"
3636
"Release Notes" = "https://github.com/python-thread/thread/releases"

src/thread/__init__.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
"""
22
## Thread Library
3-
Documentation at https://thread.ngjx.org/docs/v1.1.1
3+
Documentation at https://thread.ngjx.org/docs/2.0.0
44
55
66
---
77
8-
Released under the GPG-3 License
8+
Released under the BSD-3 License
99
1010
Copyright (c) thread.ngjx.org, All rights reserved
1111
"""
@@ -18,11 +18,11 @@
1818
"""
1919

2020

21-
__version__ = '1.1.1'
21+
__version__ = '2.0.0'
2222

2323

2424
# Export Core
25-
from .thread import Thread, ParallelProcessing
25+
from .thread import Thread, ConcurrentProcessing
2626

2727

2828
from . import _types as types, exceptions
@@ -39,7 +39,7 @@
3939
# Wildcard Export
4040
__all__ = [
4141
'Thread',
42-
'ParallelProcessing',
42+
'ConcurrentProcessing',
4343
'threaded',
4444
'processor',
4545
'types',

src/thread/_types.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""
22
## Types
33
4-
Documentation: https://thread.ngjx.org/docs/v1.1.1
4+
Documentation: https://thread.ngjx.org/docs/v2.0.0
55
"""
66

77
from typing import Any, Literal, Callable, Union, Sized

src/thread/decorators/_processor.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
"""
22
## Processor
33
4-
Documentation: https://thread.ngjx.org/docs/v1.1.1
4+
Documentation: https://thread.ngjx.org/docs/v2.0.0
55
"""
66

77
from functools import wraps
8-
from ..thread import ParallelProcessing
8+
from ..thread import ConcurrentProcessing
99

1010
from .._types import (
1111
Overflow_In,
@@ -29,22 +29,23 @@
2929

3030
NoParamReturn = Callable[
3131
Concatenate[Dataset[_DataT], _TargetP],
32-
ParallelProcessing[_TargetP, _TargetT, _DataT],
32+
ConcurrentProcessing[_TargetP, _TargetT, _DataT],
3333
]
3434
WithParamReturn = Callable[
3535
[TargetFunction[_DataT, _TargetP, _TargetT]],
3636
NoParamReturn[_DataT, _TargetP, _TargetT],
3737
]
3838
FullParamReturn = Callable[
3939
Concatenate[Dataset[_DataT], _TargetP],
40-
ParallelProcessing[_TargetP, _TargetT, _DataT],
40+
ConcurrentProcessing[_TargetP, _TargetT, _DataT],
4141
]
4242

4343

4444
@overload
4545
def processor(
4646
__function: TargetFunction[_DataT, _TargetP, _TargetT],
47-
) -> NoParamReturn[_DataT, _TargetP, _TargetT]: ...
47+
) -> NoParamReturn[_DataT, _TargetP, _TargetT]:
48+
...
4849

4950

5051
@overload
@@ -55,7 +56,8 @@ def processor(
5556
ignore_errors: Sequence[type[Exception]] = (),
5657
suppress_errors: bool = False,
5758
**overflow_kwargs: Overflow_In,
58-
) -> WithParamReturn[_DataT, _TargetP, _TargetT]: ...
59+
) -> WithParamReturn[_DataT, _TargetP, _TargetT]:
60+
...
5961

6062

6163
@overload
@@ -67,7 +69,8 @@ def processor(
6769
ignore_errors: Sequence[type[Exception]] = (),
6870
suppress_errors: bool = False,
6971
**overflow_kwargs: Overflow_In,
70-
) -> FullParamReturn[_DataT, _TargetP, _TargetT]: ...
72+
) -> FullParamReturn[_DataT, _TargetP, _TargetT]:
73+
...
7174

7275

7376
def processor(
@@ -150,15 +153,15 @@ def wrapped(
150153
data: Dataset[_DataT],
151154
*parsed_args: _TargetP.args,
152155
**parsed_kwargs: _TargetP.kwargs,
153-
) -> ParallelProcessing[_TargetP, _TargetT, _DataT]:
156+
) -> ConcurrentProcessing[_TargetP, _TargetT, _DataT]:
154157
kwargs.update(parsed_kwargs)
155158

156159
processed_args = (*args, *parsed_args)
157160
processed_kwargs = {
158161
i: v for i, v in kwargs.items() if i not in ['args', 'kwargs']
159162
}
160163

161-
job = ParallelProcessing(
164+
job = ConcurrentProcessing(
162165
function=__function,
163166
dataset=data,
164167
args=processed_args,

src/thread/decorators/_threaded.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""
22
## Threaded
33
4-
Documentation: https://thread.ngjx.org/docs/v1.1.1
4+
Documentation: https://thread.ngjx.org/docs/v2.0.0
55
"""
66

77
from functools import wraps
@@ -23,7 +23,8 @@
2323

2424

2525
@overload
26-
def threaded(__function: TargetFunction[P, T]) -> NoParamReturn[P, T]: ...
26+
def threaded(__function: TargetFunction[P, T]) -> NoParamReturn[P, T]:
27+
...
2728

2829

2930
@overload
@@ -34,7 +35,8 @@ def threaded(
3435
ignore_errors: Sequence[type[Exception]] = (),
3536
suppress_errors: bool = False,
3637
**overflow_kwargs: Overflow_In,
37-
) -> WithParamReturn[P, T]: ...
38+
) -> WithParamReturn[P, T]:
39+
...
3840

3941

4042
@overload
@@ -46,7 +48,8 @@ def threaded(
4648
ignore_errors: Sequence[type[Exception]] = (),
4749
suppress_errors: bool = False,
4850
**overflow_kwargs: Overflow_In,
49-
) -> FullParamReturn[P, T]: ...
51+
) -> FullParamReturn[P, T]:
52+
...
5053

5154

5255
def threaded(

src/thread/exceptions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""
22
## Thread Exceptions
33
4-
Documentation: https://thread.ngjx.org/docs/v1.1.1
4+
Documentation: https://thread.ngjx.org/docs/v2.0.0
55
"""
66

77
import traceback

src/thread/thread.py

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
class Thread: ...
66
77
8-
class ParallelProcessing: ...
8+
class ConcurrentProcessing: ...
99
```
1010
11-
Documentation: https://thread.ngjx.org/docs/v1.1.1
11+
Documentation: https://thread.ngjx.org/docs/v2.0.0
1212
"""
1313

1414
import sys
@@ -230,18 +230,14 @@ def add_hook(self, hook: HookFunction[_Target_T]) -> None:
230230
"""
231231
self.hooks.append(hook)
232232

233-
def join(self, timeout: Optional[float] = None) -> bool:
233+
def join(self, timeout: Optional[float] = None) -> None:
234234
"""
235235
Halts the current thread execution until a thread completes or exceeds the timeout
236236
237237
Parameters
238238
----------
239239
:param timeout: The maximum time allowed to halt the thread
240240
241-
Returns
242-
-------
243-
:returns bool: True if the thread is no-longer alive
244-
245241
Raises
246242
------
247243
ThreadNotInitializedError: If the thread is not initialized
@@ -255,7 +251,6 @@ def join(self, timeout: Optional[float] = None) -> bool:
255251

256252
super().join(timeout)
257253
self._handle_exceptions()
258-
return not self.is_alive()
259254

260255
def get_return_value(self) -> _Target_T:
261256
"""
@@ -341,9 +336,9 @@ def __init__(self, thread: Thread, progress: float = 0) -> None:
341336
self.progress = progress
342337

343338

344-
class ParallelProcessing(Generic[_Target_P, _Target_T, _Dataset_T]):
339+
class ConcurrentProcessing(Generic[_Target_P, _Target_T, _Dataset_T]):
345340
"""
346-
Multi-Threaded Parallel Processing
341+
Concurrent Processing
347342
---------------------------------------
348343
349344
Type-Safe and provides more functionality on top
@@ -378,7 +373,8 @@ def __init__(
378373
_get_value: Optional[Callable[[LengthandGetLike_T, int], _Dataset_T]] = None,
379374
_length: Optional[Union[int, Callable[[Any], int]]] = None,
380375
**overflow_kwargs: Overflow_In,
381-
) -> None: ...
376+
) -> None:
377+
...
382378

383379
# Has __len__, require _get_value to be set
384380
@overload
@@ -391,7 +387,8 @@ def __init__(
391387
_get_value: Callable[[LengthLike_T, int], _Dataset_T],
392388
_length: Optional[Union[int, Callable[[Any], int]]] = None,
393389
**overflow_kwargs: Overflow_In,
394-
) -> None: ...
390+
) -> None:
391+
...
395392

396393
# Has __getitem__, require _length to be set
397394
@overload
@@ -404,7 +401,8 @@ def __init__(
404401
_get_value: Optional[Callable[[GetLike_T, int], _Dataset_T]] = None,
405402
_length: Union[int, Callable[[GetLike_T], int]],
406403
**overflow_kwargs: Overflow_In,
407-
) -> None: ...
404+
) -> None:
405+
...
408406

409407
# Does not support __getitem__ and __len__
410408
@overload
@@ -417,7 +415,8 @@ def __init__(
417415
_get_value: Callable[[Any, int], _Dataset_T],
418416
_length: Union[int, Callable[[Any], int]],
419417
**overflow_kwargs: Overflow_In,
420-
) -> None: ...
418+
) -> None:
419+
...
421420

422421
def __init__(
423422
self,
@@ -442,10 +441,10 @@ def __init__(
442441
**overflow_kwargs: Overflow_In,
443442
) -> None:
444443
"""
445-
Initializes a new Multi-Threaded Pool\n
444+
Initializes a new Concurrent Process\n
446445
Best for data processing
447446
448-
Splits a dataset as evenly as it can among the threads and run them in parallel
447+
Splits a dataset as evenly as it can among the threads and run them concurrently
449448
450449
Parameters
451450
----------
@@ -598,14 +597,10 @@ def get_return_values(self) -> List[_Dataset_T]:
598597
results += entry.thread.result
599598
return results
600599

601-
def join(self) -> bool:
600+
def join(self) -> None:
602601
"""
603602
Halts the current thread execution until a thread completes or exceeds the timeout
604603
605-
Returns
606-
-------
607-
:returns bool: True if the thread is no-longer alive
608-
609604
Raises
610605
------
611606
ThreadNotInitializedError: If the thread is not initialized
@@ -619,7 +614,6 @@ def join(self) -> bool:
619614

620615
for entry in self._threads:
621616
entry.thread.join()
622-
return True
623617

624618
def kill(self) -> None:
625619
"""

0 commit comments

Comments
 (0)