Skip to main content

Select the concurrent.futures backend at runtime

Project description

Futures backends

Selects a concurrent.futures backend at runtime.

Import this module and you can write your code like this:

with futures_backends.select_backend( ) as executor:
    futures = [executor.submit(func, arg) for arg in args]
    for future in as_completed(futures):
        _ = future.result()

The backend can then be selected in a different place to the computational code.

So far, we have:

  • 'loky' : https://github.com/joblib/loky
  • 'thread' : concurrent.futures.ThreadPoolExecutor
  • 'fork' : concurrent.futures.ProcessPoolExecutor with mp_context = 'fork'
  • 'forkserver' : concurrent.futures.ProcessPoolExecutor with mp_context = 'forkserver'
  • 'spawn' : concurrent.futures.ProcessPoolExecutor with mp_context = 'spawn'

In the future we would like to add others like pyslurmutils and mpi4py, etc.

Credits

Thanks to Google's Gemini and OpenAI's chatgpt for many useful suggestions when writing this code.

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

futures_backends-0.0.1.tar.gz (7.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

futures_backends-0.0.1-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

Details for the file futures_backends-0.0.1.tar.gz.

File metadata

  • Download URL: futures_backends-0.0.1.tar.gz
  • Upload date:
  • Size: 7.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for futures_backends-0.0.1.tar.gz
Algorithm Hash digest
SHA256 6b2aab28e9d5a1c0baffe9c9f057790a7c87dffca473b9bc644129ed9ed6ec0c
MD5 67133480a2ca84e69cfec88c323b8d49
BLAKE2b-256 3ecc35f5257fac2b2cfcb2f4310cef9a586af69e50911b8fc64bcb4fa6d3d8af

See more details on using hashes here.

File details

Details for the file futures_backends-0.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for futures_backends-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 38827fa64fc4dbddadc0fc6aa2470b2e79f898886b4769078405026a71992e74
MD5 32111c832221baa49a437aae3ee5bc72
BLAKE2b-256 c783bafa6599875c595269e88b041b1cdc322d5cb93cf42695a7e3b132e73739

See more details on using hashes here.

Supported by

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