Skip to main content

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.

Metadata

Release files for futures-backends 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for futures-backends 0.0.1
File Size Uploaded
futures_backends-0.0.1.tar.gz 7.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for futures-backends 0.0.1
File Interpreter ABI Platform
futures_backends-0.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 12.8 kB

Release files / futures_backends-0.0.1.tar.gz

Download URL futures_backends-0.0.1.tar.gz
Size 7.0 kB
Tags Source
SHA-256 checksum
How to use checksums
6b2aab28e9d5a1c0baffe9c9f057790a7c87dffca473b9bc644129ed9ed6ec0c
BLAKE2b-256 checksum
How to use checksums
3ecc35f5257fac2b2cfcb2f4310cef9a586af69e50911b8fc64bcb4fa6d3d8af
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.9

Release files / futures_backends-0.0.1-py3-none-any.whl

Download URL futures_backends-0.0.1-py3-none-any.whl
Size 5.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
38827fa64fc4dbddadc0fc6aa2470b2e79f898886b4769078405026a71992e74
BLAKE2b-256 checksum
How to use checksums
c783bafa6599875c595269e88b041b1cdc322d5cb93cf42695a7e3b132e73739
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.9

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page