Gather results from multiple threads seamlessly.
Project description
Thread Wrapper Class
Gather results from multiple threads seamlessly.
Hierarchy
threadwrapper
'---- ThreadWrapper()
|---- add()
'---- wait()
Example
python
from threadwrapper import *
from omnitools import def_template
def a(b, c=None):
return f"{b}, {c}"
tw = ThreadWrapper(threading.Semaphore(1))
result = {}
for i in range(10):
# def_template(_def, *args, **kwargs)() is same as
# _def(*args, **kwargs)
tw.add(job=def_template(a, i**2, c=i**3), result=result, key=i)
tw.wait()
print(result)
# {0: '0, 0', 1: '1, 1', 2: '4, 8', 3: '9, 27', 4: '16, 64', 5: '25, 125', 6: '36, 216', 7: '49, 343', 8: '64, 512', 9: '81, 729'}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
threadwrapper-0.8.0.tar.gz
(15.9 kB
view hashes)
Built Distribution
Close
Hashes for threadwrapper-0.8.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4e9b9bd7bc87e15a9b0c8d2c4a6b0bdaa51aa5773f5c89ead2dd047c0d3fe77b |
|
MD5 | 369351e64a4f62966500c0fb85b3e27e |
|
BLAKE2b-256 | 980acd3d2d02a045e094944564768a18f22995c3589c1046817fcc34e4c6ae04 |