A bridge between the asynchronous and synchronous world
Project description
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
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
async-helper-0.0.3.tar.gz
(2.6 kB
view details)
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 async-helper-0.0.3.tar.gz.
File metadata
- Download URL: async-helper-0.0.3.tar.gz
- Upload date:
- Size: 2.6 kB
- Tags: Source
- Uploaded using 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
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7f7a4e4e5a84c19d52568ffa4d916a9013b9001ad82e71ca55e3a0653b10d3d8
|
|
| MD5 |
3a633529f633e32c63a9e5c5dd482db4
|
|
| BLAKE2b-256 |
8ba4adcc6a7423c6fadc41bd8f9827f1dbcb66cf71d3e65bf4be61b96a1e38d5
|
File details
Details for the file async_helper-0.0.3-py3-none-any.whl.
File metadata
- Download URL: async_helper-0.0.3-py3-none-any.whl
- Upload date:
- Size: 3.6 kB
- Tags: Python 3
- Uploaded using 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
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
638469c575e04dffd83f377cbdd1c45a1bf862009c193e7ab46d00f55e52fb31
|
|
| MD5 |
286aac74f5092f2a433ceacf03cc4f50
|
|
| BLAKE2b-256 |
f769cf308429934e1ec1a2e9657762eb80d460c11c767986eaadb0db6b9792d7
|