Skip to content

Commit 8b0399a

Browse files
refactor: Move to use concurrent
Ref: #58
1 parent 18bddea commit 8b0399a

File tree

6 files changed

+59
-57
lines changed

6 files changed

+59
-57
lines changed

README.md

Lines changed: 1 addition & 1 deletion
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>

src/thread/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
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/decorators/_processor.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
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,15 +29,15 @@
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

@@ -150,15 +150,15 @@ def wrapped(
150150
data: Dataset[_DataT],
151151
*parsed_args: _TargetP.args,
152152
**parsed_kwargs: _TargetP.kwargs,
153-
) -> ParallelProcessing[_TargetP, _TargetT, _DataT]:
153+
) -> ConcurrentProcessing[_TargetP, _TargetT, _DataT]:
154154
kwargs.update(parsed_kwargs)
155155

156156
processed_args = (*args, *parsed_args)
157157
processed_kwargs = {
158158
i: v for i, v in kwargs.items() if i not in ['args', 'kwargs']
159159
}
160160

161-
job = ParallelProcessing(
161+
job = ConcurrentProcessing(
162162
function=__function,
163163
dataset=data,
164164
args=processed_args,

src/thread/thread.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
class Thread: ...
66
77
8-
class ParallelProcessing: ...
8+
class ConcurrentProcessing: ...
99
```
1010
1111
Documentation: https://thread.ngjx.org/docs/v1.1.1
@@ -341,9 +341,9 @@ def __init__(self, thread: Thread, progress: float = 0) -> None:
341341
self.progress = progress
342342

343343

344-
class ParallelProcessing(Generic[_Target_P, _Target_T, _Dataset_T]):
344+
class ConcurrentProcessing(Generic[_Target_P, _Target_T, _Dataset_T]):
345345
"""
346-
Multi-Threaded Parallel Processing
346+
Concurrent Processing
347347
---------------------------------------
348348
349349
Type-Safe and provides more functionality on top
@@ -442,10 +442,10 @@ def __init__(
442442
**overflow_kwargs: Overflow_In,
443443
) -> None:
444444
"""
445-
Initializes a new Multi-Threaded Pool\n
445+
Initializes a new Concurrent Process\n
446446
Best for data processing
447447
448-
Splits a dataset as evenly as it can among the threads and run them in parallel
448+
Splits a dataset as evenly as it can among the threads and run them concurrently
449449
450450
Parameters
451451
----------

tests/test_parallelprocessing.py renamed to tests/test_concurrentprocessing.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import time
22
import pytest
3-
from src.thread import ParallelProcessing, exceptions
3+
from src.thread import ConcurrentProcessing, exceptions
44

55

66
# >>>>>>>>>> Dummy Functions <<<<<<<<<< #
@@ -18,7 +18,7 @@ def _dummy_raiseException(x: Exception, delay: float = 0):
1818
def test_threadsScaleDown():
1919
"""This test is for testing if threads scale down `max_threads` when the dataset is lesser than the thread count"""
2020
dataset = list(range(0, 2))
21-
new = ParallelProcessing(
21+
new = ConcurrentProcessing(
2222
function=_dummy_dataProcessor,
2323
dataset=dataset,
2424
max_threads=4,
@@ -32,7 +32,7 @@ def test_threadsScaleDown():
3232
def test_threadsProcessing():
3333
"""This test is for testing if threads correctly order data in the `dataset` arrangement"""
3434
dataset = list(range(0, 500))
35-
new = ParallelProcessing(
35+
new = ConcurrentProcessing(
3636
function=_dummy_dataProcessor, dataset=dataset, args=[0.001], daemon=True
3737
)
3838
new.start()
@@ -43,7 +43,7 @@ def test_threadsProcessing():
4343
def test_raises_StillRunningError():
4444
"""This test should raise ThreadStillRunningError"""
4545
dataset = list(range(0, 8))
46-
new = ParallelProcessing(
46+
new = ConcurrentProcessing(
4747
function=_dummy_dataProcessor, dataset=dataset, args=[1], daemon=True
4848
)
4949
new.start()
@@ -54,7 +54,7 @@ def test_raises_StillRunningError():
5454
def test_raises_RunTimeError():
5555
"""This test should raise a RunTimeError"""
5656
dataset = [RuntimeError()] * 8
57-
new = ParallelProcessing(
57+
new = ConcurrentProcessing(
5858
function=_dummy_raiseException, dataset=dataset, args=[0.01], daemon=True
5959
)
6060
with pytest.raises(RuntimeError):

0 commit comments

Comments
 (0)