The simplest way to utilize multiple threads, processes, and asynchronous in Python
Project description
Parallely - Parallel Python made simple
Installation
pip install paralelly
Multi Threading
from parallely import threaded
import requests
@threaded(max_workers=500)
def fetch_data(url):
return requests.get(url).json()
# Use the function as usual for fine grained control, testing etc.
fetch_data("http://www.SOME-WEBSITE.com/data/cool-stuff")
# Use a thread-pool to map over a list of inputs in concurrent manner
fetch_data.map([
"http://www.SOME-WEBSITE.com/data/cool-stuff",
"http://www.SOME-WEBSITE.com/data/cool-stuff",
"http://www.SOME-WEBSITE.com/data/cool-stuff"
])
from parallely import threaded
import requests
@threaded
def fetch(min_val=100, max_val=1000, count=5):
return requests.get(f"http://www.randomnumberapi.com/api/v1.0/random?min={min_val}&max={max_val}&count={count}").json()
fetch.map(count=list(range(10)))
Multi Processing
Asynchronous
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
parallely-0.2.0.tar.gz
(185.7 kB
view hashes)
Built Distribution
parallely-0.2.0-py3-none-any.whl
(14.3 kB
view hashes)
Close
Hashes for parallely-0.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a49f108c6358efed865150d78e86a605682f05c1193e415bc1cce8fb76a6eae6 |
|
MD5 | 39ffd3ec08cf5985d51b2a6986f5e364 |
|
BLAKE2b-256 | 522d7b7376901bf8a8aa7012ed85b6628f211eb415f50de75eaea740a8393f71 |