Skip to main content

FuturePool is a package that introduce known concept of multiprocessing Pool to the async/await world, resulting in async workers pool library. It allows for easy translation from multiprocessing to async/await, while keeping the core principle - specified number of workers. FuturePool allows for more flexible usage by providing starimap/starimap_unordered.

Project description

FuturePool PyPI - Version

FuturePool is a package that introduce known concept of multiprocessing Pool to the async/await world, resulting in async workers pool library. It allows for easy translation from multiprocessing to async/await, while keeping the core principle - specified number of workers. FuturePool allows for more flexible usage by providing starimap/starimap_unordered.

FuturePool was created to handle web scrapping, where in order to not overwhelm website with connections and comply with website requirements, specified number of workers was used. FuturePool was extended to handle generic scenarios and published.

License

MIT

Example

To see library docs visit https://MichalKarol.github.io/futurepool/.

Example translation from multiprocessing to FuturePool

# multiprocessing
from multiprocessing import Pool
from time import sleep

def pool_fn(i):
    sleep(i)
    return i

with Pool(2) as p:
    result = p.map(pool_fn, range(10))
# FuturePool
from futurepool import FuturePool
from asyncio import sleep

async def async_pool_fn(i):
    await sleep(i)
    return i

async with FuturePool(2) as fp:
    result = await fp.map(async_pool_fn, range(10))

Author

Michał Karol michal.p.karol@gmail.com
Mastodon
Github

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

futurepool-1.0.1.tar.gz (4.8 kB view details)

Uploaded Source

Built Distribution

futurepool-1.0.1-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

Details for the file futurepool-1.0.1.tar.gz.

File metadata

  • Download URL: futurepool-1.0.1.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for futurepool-1.0.1.tar.gz
Algorithm Hash digest
SHA256 08aff857e2e11a012cbfbb82db4f26c9f5d71281435720788f889e5eaa7268ba
MD5 e402f63e35853763e81bfcefa9dea2ff
BLAKE2b-256 c6a857d53594498f6999683b47e0d955a7f88222081ba798e097ad0eb370185a

See more details on using hashes here.

File details

Details for the file futurepool-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: futurepool-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 5.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for futurepool-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7ccf7f489bfec81333a36ecfd22a319f5d48031d4eac42c6d683e5940947f97b
MD5 6856d031f0e786cfc2d02dd4e4f05219
BLAKE2b-256 e33c166f5777faf1ade3ad93b3a569f64e8aea9968bb0cefb23d7fa6031f8b5f

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