Skip to main content

A simple and easy way to use asyncio & aiohttp libraries.

Project description

AIOEase

AIOEase simplifies asynchronous HTTP requests in Python, offering a straightforward interface for handling multiple requests asynchronously with rate limiting. Proved a list of dictionaries and the requests_per_second_max (default 1). Returns the status, response, and request as a list of dictionaries.

Installation

pip install aioease

Usage

Execute multiple HTTP requests asynchronously with ease:

from aioease import execute_async_requests

requests = [
    {"url": "https://httpbin.org/ip", "method": "get", "data": {"key": "value"}, "headers": {"header": "value"}},
    {"url": "https://httpbin.org/ip", "method": "post", "data": {"key": "value"}, "headers": {"header": "value"}},
]

responses = execute_async_requests(requests, requests_per_second_max=10)

Returns:

responses = [
  {
    "status": 200,
    "response": "{\n  \"origin\": \"00.000.00.000\"\n}\n",
  },
  {
    "status": 405,
    "response": "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2 Final//EN\">\n<title>405 Method Not Allowed</title>\n<h1>Method Not Allowed</h1>\n<p>The method is not allowed for the requested URL.</p>\n",
  }
]

Given a unique identifyer to match requests to the responses.

from aioease import execute_async_requests

requests = [
    {"url": "https://httpbin.org/ip", "method": "get", "data": {"key": "value"}, "headers": {"header": "value"},"id": "unique-identifyer-1"},
    {"url": "https://httpbin.org/ip", "method": "post", "data": {"key": "value"}, "headers": {"header": "value"},"id": "unique-identifyer-2"},
]

responses = execute_async_requests(requests, requests_per_second_max=10)

Returns:

responses = [
  {
    "status": 200,
    "response": "{\n  \"origin\": \"00.000.00.000\"\n}\n",
    "id": "unique-identifyer-1"
  },
  {
    "status": 405,
    "response": "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2 Final//EN\">\n<title>405 Method Not Allowed</title>\n<h1>Method Not Allowed</h1>\n<p>The method is not allowed for the requested URL.</p>\n",
    "id": "unique-identifyer-2"
  }
]

Configuring Logging

Control the verbosity of logs for debugging:

import logging

logging.basicConfig(level=logging.INFO)
logging.basicConfig(level=logging.DEBUG)
logging.basicConfig(level=logging.ERROR)

License

Available under the MIT License.

Support

For support, please open an issue on the GitHub issue tracker.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

aioease-0.1.26-py3-none-any.whl (4.0 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