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, result=result, key=i, args=args(i**2, c=i**3))
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.0.5.tar.gz
(2.9 kB
view hashes)
Built Distribution
Close
Hashes for threadwrapper-0.0.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d24487169bd116906a8550828b9bea0c693179c30dc6e2411a30cae4fe2b9bfa |
|
MD5 | 25d28854bd1e0513aa81089c43f84570 |
|
BLAKE2b-256 | 9bf7897d0a50e501de7fb99c07187d64552f4a52e3941aff1cf21aaabe0a7fff |