https://github.com/ryzeon-dev/rythreadpool
Multi-threading library
https://github.com/ryzeon-dev/rythreadpool
multithreading python3 threading
Last synced: about 1 month ago
JSON representation
Multi-threading library
- Host: GitHub
- URL: https://github.com/ryzeon-dev/rythreadpool
- Owner: ryzeon-dev
- License: agpl-3.0
- Created: 2025-01-13T10:35:42.000Z (5 months ago)
- Default Branch: master
- Last Pushed: 2025-01-13T10:35:57.000Z (5 months ago)
- Last Synced: 2025-03-29T14:42:55.288Z (2 months ago)
- Topics: multithreading, python3, threading
- Language: Python
- Homepage:
- Size: 11.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ThreadPool library
- Multi-threading library
- Allows to limit the number of threads to a fixed number## Install
```
pip install rythreapool
```## Usage
- import the library
```python
import threadpool
```
- create a new ThreadPool, giving as argument the number of desidred parallel threads
- it is suggested to never exceed the number of physical threads that your processor has
```python
pool = threadpool.ThreadPool(16)
```
- now it is possible to run multiple functions or tasks
```python
pool.execute(fn=myTask, args=())
```
- to check if the threadpool is busy, use the following function
- returns `True` if the pool is working, otherwise returns `False`
```python
pool.isWorking()
```### Notes
1. remember that, if a task implements active waiting, it will keep its thread busy until the end of execution
2. once reaced the limit of parallel threads, all the following tasks will have to wait for a thread to become free