Skip to main content

Gather results from multiple threads seamlessly.

Project description

Thread Wrapper Class

<badges>version license pyversions
donate powered made </badges>

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for threadwrapper, version 0.6.0
Filename, size File type Python version Upload date Hashes
Filename, size threadwrapper-0.6.0-py3-none-any.whl (15.3 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size threadwrapper-0.6.0.tar.gz (2.9 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page