ThreadedProcessPoolExecutor
The ThreadedProcessPoolExecutor class is an Executor subclass that uses a pool of process with an inner pool of threads on each process to execute calls asynchronously.
ThreadedProcessPoolExecutor is formed by a modified ProcessPoolExecutor that processes (with at most max_processes) that use a ThreadPoolExecutor instance (with at most max_threads) to run the given tasks.
If max_processes is None or not given, it will default to the number of processors on the machine.
If max_threads is None or not given, it will default to the number of processors on the machine, multiplied by 5.
Example
from concurrent.futures import as_completed
import math
from threadedprocess import ThreadedProcessPoolExecutor
import requests
RNGURL = "https://www.random.org/integers/?num=1&min=1&max=100000000&col=1&base=10&format=plain&rnd=new"
def get_prime():
n = int(requests.get(RNGURL).text)
if n % 2 == 0:
return (n, False)
sqrt_n = int(math.floor(math.sqrt(n)))
for i in range(3, sqrt_n + 1, 2):
if n % i == 0:
return (n, False)
return (n, True)
with ThreadedProcessPoolExecutor(max_processes=4, max_threads=16) as executor:
futures = []
for _ in range(128):
futures.append(executor.submit(get_prime))
for future in as_completed(futures):
print('%d is prime: %s' % future.result())
Metadata
Release files for threadedprocess 0.0.5
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 |
|---|---|---|---|---|
| threadedprocess-0.0.5.tar.gz | 4.0 kB | Without provenance | Details for threadedprocess-0.0.5.tar.gz |
Release files / threadedprocess-0.0.5.tar.gz
| Download URL | threadedprocess-0.0.5.tar.gz |
|---|---|
| Size | 4.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
712e8b711eefc82e052857b0a5b1c911c987819dd9d94ccb9d7b3aeb035a46ae
|
|
BLAKE2b-256 checksum How to use checksums |
175abc35b33ea71f498823892c2c46fe1190a276b1e05eaa476f7076f5ff4ad6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for threadedprocess 0.0.5
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.