Skip to content

Commit 50a18a8

Browse files
Merge pull request #11 from caffeine-addictt/dev
V0.1.2 base
2 parents 6f31f43 + d4a8968 commit 50a18a8

File tree

13 files changed

+282
-165
lines changed

13 files changed

+282
-165
lines changed

.coverage

0 Bytes
Binary file not shown.

.github/workflows/test-worker.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: Run Python tests
22

3-
on: [ push, pull_request ]
3+
on: [ push ]
44

55
jobs:
66
build:
@@ -9,7 +9,7 @@ jobs:
99
runs-on: ubuntu-latest
1010
strategy:
1111
matrix:
12-
python-version: ["3.11", "3.x"]
12+
python-version: ["3.9", "3.10", "3.11", "3.x"]
1313

1414

1515
steps:

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Python stuff
2-
venv/
2+
venv*/
33
*.pytest_cache
44
__pycache__/
55

LICENSE

Lines changed: 0 additions & 21 deletions
This file was deleted.

LICENSE.txt

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
BSD 3-Clause License
2+
3+
Copyright (c) 2023, Jun Xiang
4+
5+
Redistribution and use in source and binary forms, with or without
6+
modification, are permitted provided that the following conditions are met:
7+
8+
1. Redistributions of source code must retain the above copyright notice, this
9+
list of conditions and the following disclaimer.
10+
11+
2. Redistributions in binary form must reproduce the above copyright notice,
12+
this list of conditions and the following disclaimer in the documentation
13+
and/or other materials provided with the distribution.
14+
15+
3. Neither the name of the copyright holder nor the names of its
16+
contributors may be used to endorse or promote products derived from
17+
this software without specific prior written permission.
18+
19+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

README.md

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
[![Forks][forks-shield]][forks-url]
1515
[![Stargazers][stars-shield]][stars-url]
1616
[![Issues][issues-shield]][issues-url]
17-
[![MIT License][license-shield]][license-url]
17+
[![BSD-3-Clause License][license-shield]][license-url]
1818
[![LinkedIn][linkedin-shield]][linkedin-url]
1919

2020
<!-- PROJECT LOGO -->
@@ -54,14 +54,6 @@ I hope thread will become your threading solution! ♡⸜(˶˃ ᵕ ˂˶)⸝♡
5454

5555

5656

57-
### Built With
58-
59-
* [![Python 3.11.6+](https://img.shields.io/badge/python-3.11.6+-blue.svg)](https://www.python.org/downloads/release/python-3116/)
60-
61-
<p align="right">(<a href="#readme-top">back to top</a>)</p>
62-
63-
64-
6557
<!-- GETTING STARTED -->
6658
## Getting Started
6759

@@ -70,7 +62,7 @@ To get a local copy up and running follow these simple example steps.
7062

7163
### Prerequisites
7264

73-
* Python 3.10+
65+
* Python 3.9+
7466

7567
### Installation
7668

@@ -102,12 +94,11 @@ Our docs are [here!](/docs/getting-started.md)
10294
<!-- ROADMAP -->
10395
## Roadmap
10496

105-
- [x] 0.0.1 Release
10697
- [x] Bug fixes
107-
- [x] 0.1.0 Release
108-
- [x] 0.1.1 Hotfix
109-
- [ ] New Features
110-
- [ ] 0.1.1 Release
98+
- [x] Set Thread class to inherit from threading.Thread
99+
- [ ] Add kill method
100+
- [ ] Docs Update
101+
- [ ] v0.1.2 Release
111102

112103
See the [open issues](https://github.com/caffeine-addictt/thread/issues) for a full list of proposed features (and known issues).
113104

@@ -136,7 +127,7 @@ Don't forget to give the project a star! Thanks again!
136127
<!-- LICENSE -->
137128
## License
138129

139-
Distributed under the MIT License. See `LICENSE.txt` for more information.
130+
Distributed under the BSD-3-Clause License. See `LICENSE.txt` for more information.
140131

141132
<p align="right">(<a href="#readme-top">back to top</a>)</p>
142133

poetry.lock

Lines changed: 12 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name = "thread"
33
version = "0.1.1"
44
description = "Threading module extension"
55
authors = ["Alex <taboez4life@gmail.com>"]
6-
license = "MIT"
6+
license = "BSD-3-Clause"
77
readme = "README.md"
88
packages = [{include = "thread", from = "src"}]
99
include = [{ path = "tests", format = "sdist" }]
@@ -14,15 +14,16 @@ keywords = ["threading", "extension", "multiprocessing"]
1414
classifiers = [
1515
"Development Status :: 1 - Planning",
1616
"Intended Audience :: Developers",
17-
"License :: OSI Approved :: MIT License"
17+
"License :: OSI Approved :: BSD License"
1818
]
1919

2020
[tool.poetry.urls]
2121
"Bug Tracker" = "https://github.com/caffeine-addictt/thread/issues"
2222

2323
[tool.poetry.dependencies]
24-
python = "^3.11"
24+
python = "^3.9"
2525
numpy = "^1.26.2"
26+
typing-extensions = "^4.8.0"
2627

2728

2829
[tool.poetry.group.dev.dependencies]

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
numpy==1.26.2
2+
typing_extensions==4.8.0

src/thread/exceptions.py

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import traceback
2-
from typing import Any, Optional
2+
from typing import Any, Optional, Sequence, Tuple
33

44

55
class ThreadErrorBase(Exception):
@@ -20,17 +20,37 @@ class ThreadNotRunningError(ThreadErrorBase):
2020

2121
class ThreadNotInitializedError(ThreadErrorBase):
2222
"""Exception class for attempting to invoke a method which requires the thread to be initialized, but isn't"""
23-
message: str = 'Thread is not initialized, unable to invoke method. Have you ran `Thread.start()` at least once?'
23+
message: str = 'Thread is not initialized, unable to invoke method.'
2424

2525
class HookRuntimeError(ThreadErrorBase):
2626
"""Exception class for hook runtime errors"""
2727
message: str = 'Encountered runtime errors in hooks'
2828
count: int = 0
2929

30-
def add_exception_case(self, func_name: str, error: Exception):
31-
self.count += 1
32-
trace = '\n'.join(traceback.format_stack())
33-
34-
self.add_note(f'\n{self.count}. {func_name}\n>>>>>>>>>>')
35-
self.add_note(f'{trace}\n{error}')
36-
self.add_note('<<<<<<<<<<')
30+
def __init__(self, message: Optional[str] = '', extra: Sequence[Tuple[Exception, str]] = []) -> None:
31+
"""
32+
Extra for parsing all hooks that errored
33+
34+
Parameters
35+
----------
36+
:param message: The message to be parsed, can be left blank
37+
:param extra: Tuple of (Exception_Raised, function_name)
38+
"""
39+
new_message: str = message or self.message
40+
41+
for i, v in enumerate(extra):
42+
trace = '\n'.join(traceback.format_stack())
43+
new_message += f'\n\n{i}. {v[1]}\n>>>>>>>>>>'
44+
new_message += f'{trace}\n{v[0]}'
45+
new_message += '<<<<<<<<<<'
46+
super().__init__(new_message)
47+
48+
49+
# Python 3.9 doesn't support Exception.add_note()
50+
# def add_exception_case(self, func_name: str, error: Exception):
51+
# self.count += 1
52+
# trace = '\n'.join(traceback.format_stack())
53+
54+
# self.add_note(f'\n{self.count}. {func_name}\n>>>>>>>>>>')
55+
# self.add_note(f'{trace}\n{error}')
56+
# self.add_note('<<<<<<<<<<')

0 commit comments

Comments
 (0)