async-helper
async-helper by Sebastian Steins
Licence: MIT
Usage
import time, random
from async_helper import first_parallel_result
def time_consuming_function(i):
print("I consume a lot of time")
time.sleep(random.randint(1, 10))
return i
candidates = [
lambda: time_consuming_function(1),
lambda: time_consuming_function(2),
]
best_effort_result = first_parallel_result(candidates)
print(best_effort_result)
Giving preference
import time, random
from async_helper import first_parallel_result
def time_consuming_function(i):
print("I consume a lot of time")
time.sleep(random.randint(1, 10))
return i
candidates = [
0, lambda: time_consuming_function(1), # This callable will start immediately.
1, lambda: time_consuming_function(2), # This callable will start with `1` sec delay.
]
best_effort_result = first_parallel_result(candidates)
print(best_effort_result)
© 2021 Sebastian Steins
Metadata
Release files for async-helper 0.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| async-helper-0.0.3.tar.gz | 2.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| async_helper-0.0.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 6.2 kB
Release files / async-helper-0.0.3.tar.gz
| Download URL | async-helper-0.0.3.tar.gz |
|---|---|
| Size | 2.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7f7a4e4e5a84c19d52568ffa4d916a9013b9001ad82e71ca55e3a0653b10d3d8
|
|
BLAKE2b-256 checksum How to use checksums |
8ba4adcc6a7423c6fadc41bd8f9827f1dbcb66cf71d3e65bf4be61b96a1e38d5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.1
|
Release files / async_helper-0.0.3-py3-none-any.whl
| Download URL | async_helper-0.0.3-py3-none-any.whl |
|---|---|
| Size | 3.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
638469c575e04dffd83f377cbdd1c45a1bf862009c193e7ab46d00f55e52fb31
|
|
BLAKE2b-256 checksum How to use checksums |
f769cf308429934e1ec1a2e9657762eb80d460c11c767986eaadb0db6b9792d7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.1
|