Skip to content

Commit 262e3fb

Browse files
Merge pull request #3 from caffeine-addictt/dev
Version 0.0.1
2 parents 89382c5 + 36dc34f commit 262e3fb

File tree

15 files changed

+851
-11
lines changed

15 files changed

+851
-11
lines changed

.coverage

52 KB
Binary file not shown.

.github/workflows/test-worker.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
runs-on: ubuntu-latest
1010
strategy:
1111
matrix:
12-
python-version: ["3.8", "3.9", "3.10", "3.11", "3.x"]
12+
python-version: ["3.11", "3.x"]
1313

1414

1515
steps:
@@ -29,7 +29,7 @@ jobs:
2929
- name: Lint with Ruff
3030
run: |
3131
python -m pip install -U ruff
32-
ruff -v .
32+
ruff -v --per-file-ignores="__init__.py:F401" .
3333
continue-on-error: true
3434

3535
- name: Test with pytest

README.md

Lines changed: 180 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,180 @@
1+
<a name="readme-top"></a>
2+
3+
4+
5+
<!-- PROJECT SHIELDS -->
6+
<!--
7+
*** I'm using markdown "reference style" links for readability.
8+
*** Reference links are enclosed in brackets [ ] instead of parentheses ( ).
9+
*** See the bottom of this document for the declaration of the reference variables
10+
*** for contributors-url, forks-url, etc. This is an optional, concise syntax you may use.
11+
*** https://www.markdownguide.org/basic-syntax/#reference-style-links
12+
-->
13+
[![Contributors][contributors-shield]][contributors-url]
14+
[![Forks][forks-shield]][forks-url]
15+
[![Stargazers][stars-shield]][stars-url]
16+
[![Issues][issues-shield]][issues-url]
17+
[![MIT License][license-shield]][license-url]
18+
[![LinkedIn][linkedin-shield]][linkedin-url]
19+
20+
<!-- PROJECT LOGO -->
21+
<br />
22+
<div align="center">
23+
<h3 align="center">Thread</h3>
24+
25+
<p align="center">
26+
A python threading library extension
27+
<br />
28+
<a href="https://github.com/caffeine-addictt/thread/issues">Report Bug</a>
29+
·
30+
<a href="https://github.com/caffeine-addictt/thread/issues">Request Feature</a>
31+
</p>
32+
</div>
33+
34+
35+
36+
<!-- ABOUT THE PROJECT -->
37+
## About The Project
38+
> Wraps around the python threading library and provides extra functionality
39+
40+
Strictly type-safe
41+
42+
Fully compatible with the threading library, this project hopes to provide a more out-of-the-box solution with multi-threaded processing and fetching values from a completed thread, etc.
43+
44+
<br />
45+
46+
**!! Important !!**<br />
47+
THis project is in it's very early stages of development and bugs are to be expected.
48+
49+
<br />
50+
51+
I hope thread will become your threading solution! ♡⸜(˶˃ ᵕ ˂˶)⸝♡
52+
53+
<p align="right">(<a href="#readme-top">back to top</a>)</p>
54+
55+
56+
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+
65+
<!-- GETTING STARTED -->
66+
## Getting Started
67+
68+
This is an example of how you may give instructions on setting up your project locally.
69+
To get a local copy up and running follow these simple example steps.
70+
71+
### Prerequisites
72+
73+
* Python 3.10+
74+
75+
### Installation
76+
77+
_Below is an example of how you can instruct your audience on installing and setting up your app. This template doesn't rely on any external dependencies or services._
78+
79+
1. Install the package
80+
```sh
81+
pip install -U thread
82+
```
83+
2. Import thread into your library!
84+
```py
85+
import thread
86+
from thread import Thread, ...
87+
```
88+
89+
<p align="right">(<a href="#readme-top">back to top</a>)</p>
90+
91+
92+
93+
<!-- USAGE EXAMPLES -->
94+
## Usage
95+
96+
```bash
97+
# Docs soon!!
98+
```
99+
100+
<p align="right">(<a href="#readme-top">back to top</a>)</p>
101+
102+
103+
104+
<!-- ROADMAP -->
105+
## Roadmap
106+
107+
- [x] 0.0.1 Release
108+
- [ ] Bug fixes
109+
110+
See the [open issues](https://github.com/caffeine-addictt/thread/issues) for a full list of proposed features (and known issues).
111+
112+
<p align="right">(<a href="#readme-top">back to top</a>)</p>
113+
114+
115+
116+
<!-- CONTRIBUTING -->
117+
## Contributing
118+
119+
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are **greatly appreciated**. ( ˶ˆᗜˆ˵ )
120+
121+
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement".
122+
Don't forget to give the project a star! Thanks again!
123+
124+
1. Fork the Project
125+
2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`)
126+
3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`)
127+
4. Push to the Branch (`git push origin feature/AmazingFeature`)
128+
5. Open a Pull Request
129+
130+
<p align="right">(<a href="#readme-top">back to top</a>)</p>
131+
132+
133+
134+
<!-- LICENSE -->
135+
## License
136+
137+
Distributed under the MIT License. See `LICENSE.txt` for more information.
138+
139+
<p align="right">(<a href="#readme-top">back to top</a>)</p>
140+
141+
142+
143+
<!-- CONTACT -->
144+
## Contact
145+
146+
Alex - junxiangng63@gmail.com
147+
148+
Project Link: [https://github.com/caffeine-addictt/thread](https://github.com/caffeine-addictt/thread)
149+
150+
<p align="right">(<a href="#readme-top">back to top</a>)</p>
151+
152+
153+
154+
<!-- ACKNOWLEDGMENTS -->
155+
## Acknowledgments
156+
157+
* [Choose an Open Source License](https://choosealicense.com)
158+
* [GitHub Emoji Cheat Sheet](https://www.webpagefx.com/tools/emoji-cheat-sheet)
159+
* [Malven's Flexbox Cheatsheet](https://flexbox.malven.co/)
160+
* [Malven's Grid Cheatsheet](https://grid.malven.co/)
161+
* [Img Shields](https://shields.io)
162+
163+
<p align="right">(<a href="#readme-top">back to top</a>)</p>
164+
165+
166+
167+
<!-- MARKDOWN LINKS & IMAGES -->
168+
<!-- https://www.markdownguide.org/basic-syntax/#reference-style-links -->
169+
[contributors-shield]: https://img.shields.io/github/contributors/caffeine-addictt/thread.svg?style=for-the-badge
170+
[contributors-url]: https://github.com/caffeine-addictt/thread/graphs/contributors
171+
[forks-shield]: https://img.shields.io/github/forks/caffeine-addictt/thread.svg?style=for-the-badge
172+
[forks-url]: https://github.com/caffeine-addictt/thread/network/members
173+
[stars-shield]: https://img.shields.io/github/stars/caffeine-addictt/thread.svg?style=for-the-badge
174+
[stars-url]: https://github.com/caffeine-addictt/thread/stargazers
175+
[issues-shield]: https://img.shields.io/github/issues/caffeine-addictt/thread.svg?style=for-the-badge
176+
[issues-url]: https://github.com/caffeine-addictt/thread/issues
177+
[license-shield]: https://img.shields.io/github/license/caffeine-addictt/thread.svg?style=for-the-badge
178+
[license-url]: https://github.com/caffeine-addictt/thread/blob/master/LICENSE.txt
179+
[linkedin-shield]: https://img.shields.io/badge/-LinkedIn-black.svg?style=for-the-badge&logo=linkedin&colorB=555
180+
[linkedin-url]: https://www.linkedin.com/in/ngjx

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[build-system]
2+
requires = ["setuptools", "wheel"]
3+
build-backend = "setuptools.build_meta"

requirements.txt

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

setup.cfg

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[metadata]
2+
license_files = LICENSE

setup.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,33 @@
88

99
# Setting up
1010
setup(
11-
name = 'threads',
11+
name = 'thread',
1212
version = VERSION,
1313
author = 'caffeine-addictt (Jun Xiang)',
1414
author_email = '<junxiangng63@gmail.com>',
1515
description = DESCRIPTION,
1616
long_description_content_type = 'text/markdown',
1717
long_description = long_description,
18+
1819
packages = find_packages(where = 'src'),
19-
install_requires = [],
20+
package_dir = {'': 'src'},
21+
install_requires = ['numpy==1.26.2'],
2022
keywords = ['python', 'threading', 'multiprocessing'],
2123
classifiers = [
2224
'Development Status :: 1 - Planning',
2325
'Intended Audience :: Developers',
24-
'Programming Language :: Python :: 3',
26+
'License :: OSI Approved :: MIT License',
27+
'Programming Language :: Python :: 3.10',
28+
'Programming Language :: Python :: 3.11',
29+
'Programming Language :: Python :: 3 :: Only',
2530
'Operating System :: Unix',
2631
'Operating System :: MacOS :: MacOS X',
2732
'Operating System :: Microsoft :: Windows',
2833
],
29-
python_requires = '>=3.10'
34+
python_requires = '>=3.11',
35+
36+
project_urls = {
37+
'Bug Reports': 'https://github.com/caffeine-addictt/thread/issues',
38+
'Source': 'https://github.com/caffeine-addictt/thread/'
39+
}
3040
)

src/thread/__about__.py

Whitespace-only changes.

src/thread/__init__.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from .thread import (
2+
Thread,
3+
ParallelProcessing,
4+
)
5+
6+
from . import (
7+
exceptions
8+
)

src/thread/exceptions.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import traceback
2+
from typing import Any, Optional
3+
4+
5+
class ThreadErrorBase(Exception):
6+
"""Base exception class for all errors within this library"""
7+
message: str = 'Something went wrong!'
8+
def __init__(self, message: Optional[str] = None, *args: Any, **kwargs: Any) -> None:
9+
message = message or self.message
10+
super().__init__(message, *args, **kwargs)
11+
12+
13+
class ThreadStillRunningError(ThreadErrorBase):
14+
"""Exception class for attempting to invoke a method which requries the thread not be running, but isn't"""
15+
message: str = 'Thread is still running, unable to invoke method. You can wait for the thread to terminate with `Thread.join()` or check with `Thread.is_alive()`'
16+
17+
class ThreadNotRunningError(ThreadErrorBase):
18+
"""Exception class for attempting to invoke a method which requires the thread to be running, but isn't"""
19+
message: str = 'Thread is not running, unable to invoke method. Have you ran `Thread.start()`?'
20+
21+
class ThreadNotInitializedError(ThreadErrorBase):
22+
"""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?'
24+
25+
class HookRuntimeError(ThreadErrorBase):
26+
"""Exception class for hook runtime errors"""
27+
message: str = 'Encountered runtime errors in hooks'
28+
count: int = 0
29+
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('<<<<<<<<<<')

0 commit comments

Comments
 (0)