threaders
threaders is a small module to help write
clean threaded code using threading decorators
and minimize repeating copy-paste actions.
Installing
Install and update using pip:
pip install -U threaders
A Simple Example:
from threaders import threaders
import time
@threaders.threader()
def function_to_be_threaded(x):
“”” :rtype: Thread “””
t = time.time()
time.sleep(0.5*(x+0.1)/5+0.05)
return time.time()-t
def main():
# create threads
threads = []
for i in range(10):
threads.append(function_to_be_threaded(i))
# get first result
print(threaders.get_first_result(threads))
# kill threads
t = time.time()
for thread in threads:
thread.join()
print(“all threads terminated: {}”.format(time.time()-t))
if __name__ == “__main__”:
main()
Example with a thread pool:
from random import randrange
from time import sleep
import threading
delays = [randrange(1, 3) for i in range(50)]
print_lock = threading.Lock()
def wait_delay(i, d):
with print_lock:
print(‘{} sleeping for ({})sec’.format(i, d))
sleep(d)
pool = threaders.ThreadPool(10)
for i, d in enumerate(delays):
pool.put(wait_delay, i, d)
pool.join()
Metadata
Release files for threaders 0.2.13
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| threaders-0.2.13.tar.gz | 12.7 kB | Without provenance | Details for threaders-0.2.13.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| threaders-0.2.13-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details for threaders-0.2.13-py2.py3-none-any.whl |
Total release size: 23.2 kB
Release files / threaders-0.2.13.tar.gz
| Download URL | threaders-0.2.13.tar.gz |
|---|---|
| Size | 12.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c2894e2123c8493a569017b080acb2504c68ddbe671e59567179ade9509bf2a2
|
|
BLAKE2b-256 checksum How to use checksums |
432393df95f50fa5815574b8d2493203e6d2bf945a29eb7fcb4fc7cc6493270a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.7.0
|
Release files / threaders-0.2.13-py2.py3-none-any.whl
| Download URL | threaders-0.2.13-py2.py3-none-any.whl |
|---|---|
| Size | 10.5 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
24c3b3e91945e2095a3fb17a77a2a83b05ee1797fd1bfdc43d130f45ee93bdcc
|
|
BLAKE2b-256 checksum How to use checksums |
35b98851a007aef6753df9255d4283ea38278da821a7ba04e96db6ba836699e6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.7.0
|
Security for threaders 0.2.13
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.