Gather results from multiple threads seamlessly.
Project description
Thread Wrapper Class
Gather results from multiple threads seamlessly.
Hierarchy
threadwrapper
|---- ThreadWrapper()
| |---- add()
| '---- wait()
'---- args()
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):
# args() is used to collect positional and keyword arguments as is
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'}
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.4.1.tar.gz
(3.0 kB
view hashes)
Built Distribution
Close
Hashes for threadwrapper-0.4.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8d25969f1dcd38783f8ea60ef0fa157e0069b6b9fba8c6e571ca0a2234541d78 |
|
MD5 | 0d693b25436c4dd58de05490cbe6dcb2 |
|
BLAKE2b-256 | 145229778bc3e16472dd995f2230714061600cfed2847d04356769acee5a2a4e |