Skip to main content

careful

logo of a warning sign

careful is a Python library for writing resilient, well-behaved HTTP clients.

Code: https://codeberg.org/jpt/careful

Docs: https://jpt.sh/projects/careful/

PyPI - Version status-badge

Call one function to enchant an httpx2.Client, making your HTTP connections more resilient and better mannered.

  • Configure throttling to avoid accidental Denial-of-Service / risking getting banned.
  • Retries help overcome intermittent failures on flaky sites or long crawls.
  • Development caching Cache persists between runs during development, reduces redundant requests made while iterating on your crawlers & scrapers.

Example

from httpx2 import Client
from careful.httpx import make_careful_client

# the only function you need to call is make_careful_client
# this wraps your existing `httpx2.Client` with your preferred
# careful behaviors

client = make_careful_client(
    client=Client(headers={'user-agent': 'spiderman/1.0'}),

    # retries are configurable w/ exponential back off
    retry_attempts=2,
    retry_wait_seconds=5,

    # can cache to process memory, filesystem, or SQLite
    cache_storage=MemoryCache(),

    # easy-to-configure throttling
    requests_per_minute=60,
)

# methods on client are called as they always are
# configured behaviors occur without further code changes
client.get("https://example.com")

Logo licensed from Adrien Coquet via Noun Project

Download files

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

Source Distribution

careful-0.5.0.tar.gz (18.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

careful-0.5.0-py3-none-any.whl (13.1 kB view details)

Uploaded Python 3

File details

Details for the file careful-0.5.0.tar.gz.

File metadata

  • Download URL: careful-0.5.0.tar.gz
  • Upload date:
  • Size: 18.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.30 {"installer":{"name":"uv","version":"0.9.30","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"NixOS","version":"25.11","id":"xantusia","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for careful-0.5.0.tar.gz
Algorithm Hash digest
SHA256 30ba4596a84c03dea5ef9731b013eacb9f262f176655841225c93dea214d153a
MD5 e6c371839af8ff115668919367dd46d8
BLAKE2b-256 cb01eef552a8f04505927c8ebc3f542a88b2c074fd4aad025c282b8b0785538e

See more details on using hashes here.

File details

Details for the file careful-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: careful-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 13.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.30 {"installer":{"name":"uv","version":"0.9.30","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"NixOS","version":"25.11","id":"xantusia","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for careful-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c854f5a03f0d45efb88e6b61d8bba9e097f40996eb385e40d37ade900a010733
MD5 69ff0ea66c631b31013d5d934a51a994
BLAKE2b-256 793a75b2d06b449d8618bced4c690cee9e2cca26c4ca2a94afa998d0baf4a5fa

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page