Skip to main content

The simplest way to utilize multiple threads, processes, and asynchronous in Python

Project description

Parallely - Parallel Python made simple

pypi license wheel python Test Suite Coverage Status docs

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)

Uploaded Source

Built Distribution

parallely-0.2.0-py3-none-any.whl (14.3 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page