Skip to main content

Lightweight Python asyncio HTTP/1.1 client.

Project description

lowhaio CircleCI Maintainability Test Coverage


Work in progress. These docs serve as a rough design spec.


A lightweight Python asyncio HTTP/1.1 client.

Usage

The API is streaming-first: for both request and response bodies, asynchronous generators are used.

import os
from lowhaio import Pool

request, _ = Pool()

path = 'my.file'
content_length = str(os.stat(path).st_size).encode()
async def file_data():
    with open(path, 'rb') as file:
        for chunk in iter(lambda: file.read(65536), b''):
            yield chunk

code, headers, body = await request(
    b'POST', 'https://example.com/path', ((b'content-length': content_length),), file_data(),
)
async for chunk in body:
    print(chunk)

However, there are helper functions streamed and buffered when this isn't required.

from lowhaio import Pool, streamed, buffered

path = 'my.file'
content_length = str(os.stat(path).st_size).encode()
async def file_data():
    with open(path, 'rb') as f:
        file_data = file.read()

content_length = str(len(data)).encode()
code, headers, body = await request(
    b'POST', 'https://example.com/path', ((b'content-length': content_length),), streamed(file_data),
)

response = await buffered(body)

Project details


Release history Release notifications

Download files

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

Files for lowhaio, version 0.0.5
Filename, size File type Python version Upload date Hashes
Filename, size lowhaio-0.0.5-py3-none-any.whl (4.5 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size lowhaio-0.0.5.tar.gz (3.4 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page