Gather results from multiple threads seamlessly.
Project description
Thread Wrapper
Gather results from multiple threads seamlessly.
Hierarchy
threadwrapper
'---- ThreadWrapper()
|---- add()
'---- wait()
Example
python
from threadwrapper import *
def a(b, c=None):
return f"{b}, {c}"
tw = ThreadWrapper(threading.Semaphore(1))
result = {}
for i in range(10):
tw.add(job=a, args=args(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'}
shell
threadwrapper.exe
# {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.2.0.tar.gz
(3.0 kB
view hashes)
Built Distribution
Close
Hashes for threadwrapper-0.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9de0f27a75889a515ae464068e04f2f1b5627b3e6629b7193fb439b4385449e6 |
|
MD5 | 15764a54fc8173517cf988addba0b049 |
|
BLAKE2b-256 | f8be937b4e551161a7095d6d751d69c68d2f261f13f38046888758222e8345d9 |