CollapsingThreadPoolExecutor
The CollapsingThreadPoolExecutor is inspired by and compatible with the ThreadPoolExecutor from the "futures" module, it operates differently in that worker threads are handled with a stack which results in the same worker or workers doing all the work (and idle workers being destroyed).
How to install
$ pip install collapsing-thread-pool-executor
How to develop
Prerequisites
- python3 w/ pip
- python2 w/ pip
- virtualenvwrapper
- entr
Set up the environments
$ mkvirtualenv -p `which python2.7` collapsing-thread-pool-executor-py2
$ pip install .
$ pip install -r requirements.txt
$ mkvirtualenv -p `which python3` collapsing-thread-pool-executor-py3
$ pip install .
$ pip install -r requirements.txt
Watch the tests
# watch python2 tests in one window
$ workon collapsing-thread-pool-executor-py2
$ find ./ -name '*.py' | entr -c py.test -v --log-level=DEBUG collapsing_thread_pool_executor
# watch python3 tests in one window
$ workon collapsing-thread-pool-executor-py3
$ find ./ -name '*.py' | entr -c py.test -v --log-level=DEBUG collapsing_thread_pool_executor
Examples
The example below will execute some_task() 100 times; as some_task() should take a second to execute and as we've allocated 10 workers, the whole thing should take about 10 seconds.
import time
from collapsing_thread_pool_executor import CollapsingThreadPoolExecutor
def some_task():
time.sleep(1)
# all arguments are optional
pool = CollapsingThreadPoolExecutor(
workers=10,
thread_name_prefix='SomePool',
permitted_thread_age_in_seconds=60,
)
for i in range(0, 100):
pool.submit(some_task)
Metadata
Release files for collapsing-thread-pool-executor 2020.7.18
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 |
|---|---|---|---|---|
| collapsing-thread-pool-executor-2020.7.18.tar.gz | 6.4 kB | Without provenance | Details for collapsing-thread-pool-executor-2020.7.18.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| collapsing_thread_pool_executor-2020.7.18-py2-none-any.whl | Python 2 | none | any | Details for collapsing_thread_pool_executor-2020.7.18-py2-none-any.whl |
Total release size: 14.4 kB
Release files / collapsing-thread-pool-executor-2020.7.18.tar.gz
| Download URL | collapsing-thread-pool-executor-2020.7.18.tar.gz |
|---|---|
| Size | 6.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
456347998409487d43071a86166ea207b6b06c742540522e6b601c794037cad1
|
|
BLAKE2b-256 checksum How to use checksums |
a78c64c3458576dddec371ffdf9500d87f31133269391d54c3ec0f592750f75c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/46.0.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.7
|
Release files / collapsing_thread_pool_executor-2020.7.18-py2-none-any.whl
| Download URL | collapsing_thread_pool_executor-2020.7.18-py2-none-any.whl |
|---|---|
| Size | 8.0 kB |
| Tags | Python 2 |
|
SHA-256 checksum How to use checksums |
b1745c48b1127b3d6a773e66e3afe7fa7d8655de053f20e9d1f206305cdcf491
|
|
BLAKE2b-256 checksum How to use checksums |
2bd699e147945bbda09505892175abdf203a0f22046f01b645fe486d77339438
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/46.0.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.7
|
Security for collapsing-thread-pool-executor 2020.7.18
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.