manage spawned threads
Project description
threading_manager (v0.0.8)
DESCRIPTION_SHORT
Manage spawned threads
DESCRIPTION_LONG
designed to working with spawned threads
Features
- use different managers for different funcs/methods if needed
- use just one decorator to spawn threads from func / methods
- keep all spawned threads in list by ThreadItem objects
- ThreadItem keeps result/exx/is_alive attributes!
- use wait_all()
License
See the LICENSE file for license rights and limitations (MIT).
Release history
See the HISTORY.md file for release history.
Installation
pip install threading-manager
Import
from threading_manager import *
USAGE EXAMPLES
See tests and sourcecode for other examples.
1. example1.py
from threading_manager import *
count = 5
time_start = time.time()
# define victim ------------------
class ThreadManager1(ThreadsManager):
pass
class Cls:
@ThreadManager1().decorator__to_thread
def func1(self, num):
time.sleep(1)
return num * 1000
# spawn ------------------
for i in range(count):
assert Cls().func1(i) is None
assert ThreadManager1().count == count
ThreadManager1().wait_all()
assert {item.result for item in ThreadManager1().THREADS} == {num * 1000 for num in range(count)}
ThreadManager1().clear()
# spawn ------------------
for i in range(count):
assert Cls().func1(i) is None
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file threading_manager-0.0.8.tar.gz
.
File metadata
- Download URL: threading_manager-0.0.8.tar.gz
- Upload date:
- Size: 5.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.12.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8fa9ad2491b97a28b23193f116f3ab7bd3628ec60511a0ad051a33b5a62919ff |
|
MD5 | b2125d274d797e342d3d670972493d12 |
|
BLAKE2b-256 | f76b05da342aabd0cb2e8552c3df6eed9c85b30751669910e5558340a4714311 |
File details
Details for the file threading_manager-0.0.8-py3-none-any.whl
.
File metadata
- Download URL: threading_manager-0.0.8-py3-none-any.whl
- Upload date:
- Size: 5.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.12.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 983345adf8ebf5624233a1123ddc3b17d76fd2ab1bed556da6c822ebc460be71 |
|
MD5 | 0c47f95ba8fbd885d52536dea3d99f7d |
|
BLAKE2b-256 | df2ecbafacaba1ce2aa2efe3ab5206c29d31cda459b5df74d64df17996c70155 |