semvec/pypi-packages huggingface dataset:
lowhaio-chunked 0.0.5
Chunked transfer request encoding for lowhaio
Requires Python: >=3.6.3

# lowhaio-chunked [![CircleCI](https://circleci.com/gh/michalc/lowhaio-chunked.svg?style=svg)](https://circleci.com/gh/michalc/lowhaio-chunked)

Chunked transfer request encoding for [lowhaio](https://github.com/michalc/lowhaio). This is only needed if `content-length` is unknown before the body starts to transfer.


## Installation

```bash
pip install lowhaio lowhaio_chunked
```

or just copy and paste the below 8 lines of code into your project, ensuring to also follow the requirements in the LICENSE file.

```python
def chunked(body):
    async def _chunked(*args, **kwargs):
        async for chunk in body(*args, **kwargs):
            yield hex(len(chunk))[2:].encode() + b'\r\n'
            yield chunk
            yield b'\r\n'
        yield b'0\r\n\r\n'
    return _chunked
```


## Usage

Usage is very similar to standard lowhaio, except that the `body` data should be wrapped with the `chunked` function; the `transfer-encoding: chunked` header is required; and the `content-length` header should _not_ be specified.

So instead of a request like

```python
from lowhaio import Pool

request, _ = Pool()

body = ...

code, headers, body = await request(
    b'POST', 'https://example.com/path', body=body,
    headers=((b'content-length', b'1234'),),
)
```

you can write

```python
from lowhaio import Pool
from lowhaio_chunked import chunked  # Or paste in the code above

request, _ = Pool()

body = ...

code, headers, body = await request(
    b'POST', 'https://example.com/path', body=chunked(body),
    headers=((b'transfer-encoding': b'chunked'),),
)
```
lowhaio-retry 0.0.5
Wrapper that retries failed lowhaio HTTP requests
Requires Python: >=3.6.3

# lowhaio-retry

Wrapper that retries failed [lowhaio](https://github.com/michalc/lowhaio) HTTP requests. Allows retries of exceptions from failed HTTP requests.


## Installation

```bash
pip install lowhaio_retry
```


## Usage

The `request` function returned from `lowhaio.Pool` must be wrapped with `lowhaio_retry.retry`, as in the below example. This will retry the request, waiting the specified interval between retries. If the request still fails, the final exception will be bubbled up to client code.

So instead of a request like

```python
from lowhaio import Pool

request, _ = Pool()

body = ...

code, headers, body = await request(
    b'PUT', 'https://example.com/path', body=body,
    headers=((b'content-length', b'1234'),),
)
```

you can write

```python
from lowhaio import Pool, HttpConnectionError, HttpDataError
from lowhaio_retry import retry

request, _ = Pool()

retriable_request = retry(request,
    exception_intervals=(
        # Seconds to wait after each exception
        (HttpConnectionError, (0, 0, 0)),
        (HttpDataError, (0, 1, 2, 4)),
    ),
)

body = ...

code, headers, body = await retriable_request(
    b'PUT', 'https://example.com/path', body=body,
    headers=((b'content-length', b'1234'),),
)
```