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.7.0.tar.gz
(3.3 kB
view hashes)
Built Distribution
Close
Hashes for threadwrapper-0.7.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 23c874315c72b9a54680ab0bdbdb235a156ccafac6f1ed5a5efd52480c1205cd |
|
MD5 | aceb962aa629d45a9d6ece9238f5e4d6 |
|
BLAKE2b-256 | 3f3bca8b4d53b5d23f80574908b9b53ceefd802e3ef70f74462f1bd4096cf857 |