Skip to main content

FuturePool is a package that introduce known concept of multiprocessing Pool to the async/await world. 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

FuturePool is a package that introduce known concept of multiprocessing Pool to the async/await world. 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.0.tar.gz (4.6 kB view details)

Uploaded Source

Built Distribution

futurepool-1.0.0-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: futurepool-1.0.0.tar.gz
  • Upload date:
  • Size: 4.6 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.0.tar.gz
Algorithm Hash digest
SHA256 909f2cc1911ca2b143deabbb3d4172e8100f8ebd557c2db1d90ffcdce6986fbc
MD5 b0b5d5512879f0f35c2073086137df50
BLAKE2b-256 f3801a3d32c5c62ab4b0a25ed24feb9f2aedeacde3038f090ee534d6b06afb26

See more details on using hashes here.

File details

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

File metadata

  • Download URL: futurepool-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 5.2 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 494eb7b671066a9e5c514761165b1686602d1018b1dde61292b4f577023a2a0f
MD5 d532adf98d78258ed57a8a6031033929
BLAKE2b-256 4bf111a203612b3e322d3b00a36acc8c7c5e314e1b5c44099a326888b492b0a6

See more details on using hashes here.

Supported by

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