Skip to main content

Library for running tasks in bounded pool executors.

Project description

bounded_pool

PyPI version

Simplistic and universal bounded pool executor that allows to process N tasks as the same time while limiting size of the queue. Tasks can be functions or coroutines. Under the hood bounded_pool uses threads or processes, depending on used class. Refer to tests/test_basic.py for details.

Tasks will only be submited when there are available workers (specified by max_workers). You can specify max_queue_size to allow submiting more tasks than amount of available workers (so workers won't have to wait for task creation). Refer to tests/test_queue.py for details.

Example / Showcase

import time
from bounded_pool import BoundedThreadPoolExecutor


def test_example():
    futures = []

    with BoundedThreadPoolExecutor() as pool:
        for _ in range(64):
            future = pool.submit(time.sleep, 1)
            futures.append(future)

    assert futures

    for future in futures:
        assert future.done()
        assert future.result() is None

Project details


Download files

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

Source Distribution

bounded_pool-0.0.1a0.tar.gz (4.0 kB view details)

Uploaded Source

Built Distribution

bounded_pool-0.0.1a0-py3-none-any.whl (3.7 kB view details)

Uploaded Python 3

File details

Details for the file bounded_pool-0.0.1a0.tar.gz.

File metadata

  • Download URL: bounded_pool-0.0.1a0.tar.gz
  • Upload date:
  • Size: 4.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.6

File hashes

Hashes for bounded_pool-0.0.1a0.tar.gz
Algorithm Hash digest
SHA256 7cb9339e262bfbf6668fa4a323e9e511ada68aebbf25ff55d21bd432d07bc714
MD5 9eb85387ca73bcac4c0b6b601aba4c22
BLAKE2b-256 a271a4b5bd30d56ce48e97a5cdbeeee3484fef6563033bf46b796cd4290d82e9

See more details on using hashes here.

File details

Details for the file bounded_pool-0.0.1a0-py3-none-any.whl.

File metadata

File hashes

Hashes for bounded_pool-0.0.1a0-py3-none-any.whl
Algorithm Hash digest
SHA256 bf4c13a6584bb461aededc007a87efc760aab50b0177817373de0842dfeacca3
MD5 e21c7ab20e6af04a4f901c6c83c630d3
BLAKE2b-256 c7540a567863bd9167f69de22a0f348408129bb2acb4a0e83d61ddb615dd7ed4

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page