Skip to main content

aiohttphelper

PyPI PyPI - Downloads PyPI - Python Version GitHub last commit license

  1. Context
  2. Requirements
  3. Installation / Dependencies
  4. Usage
  5. Error Handling
  6. References

Context

The purpose of this package is to make a simple wrapper for aiohttp/calls in order to use it in my personnal / professional projects.

It will make one or several calls using the same session and coroutines.

Requirements

Python >= 3.6

Installation / Dependencies

pip install aiohttphelper

The following dependencies will also be installed

aiohttp[speedups]==3.6.2

Usage

First import the module:

import aiohttphelper

You have 4 functions available to you:

aiohttphelper.get(calls, headers, **kwargs)
aiohttphelper.put(calls, headers, **kwargs)
daiohttphelper.post(calls, headers, **kwargs)
aiohttphelper.delete(calls, headers, **kwargs)

Calls is a list of the urls to request. In case of put/post you need to provide a tuple (url, data):

aiohttphelper.put((url, data), headers, **kwargs)

They all return the same thing, a list of SimpleNamespace objects with the following attributes:

object.url
object.status
object.text

As it's build in top of aiohttp **kwargs is used to pass parameters to the request. Look at the documentation for more details.

⚠️ !Be carefull the default timeout for the session is 5 minutes, but you can override it:

aiohttphelper.get('dummy_url', headers='dummy_headers', timeout="10000")

Error Handling

By default all the calls that does not succed will raise an error:

aiohttp.client_exceptions.ClientResponseError

If you want to carry on with the calls even if one fails you need to pass raise_for_status=False as an argument. If you do so the result will contain the response text and response status in any successfull request.

References

aiohttp documentation

aiohttp Licence Copyright 2013-2020 aiohttp maintainers

Metadata

Release files for aiohttphelper 2.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for aiohttphelper 2.3.0
File Size Uploaded
aiohttphelper-2.3.0.tar.gz 3.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for aiohttphelper 2.3.0
File Interpreter ABI Platform
aiohttphelper-2.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 7.4 kB

Release files / aiohttphelper-2.3.0.tar.gz

Download URL aiohttphelper-2.3.0.tar.gz
Size 3.3 kB
Tags Source
SHA-256 checksum
How to use checksums
63847b59ca727378d356cf4644c4d4f7ff2164a1a24016793b199fa0eb3b637a
BLAKE2b-256 checksum
How to use checksums
e752ebc2b23a662c05dd126e2289753eb2bc5020d171aba4d92e7f51008a3da6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.2

Release files / aiohttphelper-2.3.0-py3-none-any.whl

Download URL aiohttphelper-2.3.0-py3-none-any.whl
Size 4.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
87c72e8ba944ca6a96e288d13b77a1e3f3c5cf71c91aee7344d5a7e6d5c68b0f
BLAKE2b-256 checksum
How to use checksums
6654f2fe71ba225ed026b62d75d71837fe2af17fa014ca5e22f59a9c100bba9b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.2

Release history Release notifications | RSS feed

This release

2.3.0 This release

2 release files

2.2.0

2 release files

1.0.8

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page