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.6.0.tar.gz
(2.9 kB
view hashes)
Built Distribution
Close
Hashes for threadwrapper-0.6.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2a1efe8ff84da5712ad023eca3b2ae4d5146566ce83fc19ba4bad376d1b2084f |
|
MD5 | bdf5af32ae6b7d82fb4611c7f1c40382 |
|
BLAKE2b-256 | 6de6e95a7cde39d5880b8e6fbbb1f96bcf1626ddfad36a436e81ec71f0b2f9c2 |