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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6b2aab28e9d5a1c0baffe9c9f057790a7c87dffca473b9bc644129ed9ed6ec0c
|
|
| MD5 |
67133480a2ca84e69cfec88c323b8d49
|
|
| BLAKE2b-256 |
3ecc35f5257fac2b2cfcb2f4310cef9a586af69e50911b8fc64bcb4fa6d3d8af
|
File details
Details for the file futures_backends-0.0.1-py3-none-any.whl.
File metadata
- Download URL: futures_backends-0.0.1-py3-none-any.whl
- Upload date:
- Size: 5.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
38827fa64fc4dbddadc0fc6aa2470b2e79f898886b4769078405026a71992e74
|
|
| MD5 |
32111c832221baa49a437aae3ee5bc72
|
|
| BLAKE2b-256 |
c783bafa6599875c595269e88b041b1cdc322d5cb93cf42695a7e3b132e73739
|