Skip to main content

a small library for writing resilient, well-behaved HTTP code

Project description

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 httpx.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 httpx import Client
from careful.httpx import make_careful_client

# the only function you need to call is make_careful_client
# this wraps your existing `httpx.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

Project details


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.3.1.tar.gz (19.2 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.3.1-py3-none-any.whl (11.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: careful-0.3.1.tar.gz
  • Upload date:
  • Size: 19.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.28 {"installer":{"name":"uv","version":"0.9.28","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.3.1.tar.gz
Algorithm Hash digest
SHA256 afd68b98726ebbc820769404e054b1365542f2903599f7bca286092f922f6299
MD5 079134a8bdb72250f8ba72825e3f1093
BLAKE2b-256 8d27fcef56d523aa1c1308f67004a8ab6ef70a05651700ae20f3cc4e8cf77282

See more details on using hashes here.

File details

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

File metadata

  • Download URL: careful-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 11.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.28 {"installer":{"name":"uv","version":"0.9.28","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.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 06aeaaeeb2cce3c224204bcc7a4726bbdbf7d86df2c501c350a4435c9750a99e
MD5 3351b1dfd509474936846a30bd548f1c
BLAKE2b-256 671a770bfc664e131a20de17fb244bed355ba29cdf30a36906b54f8d2135c27c

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 Pingdom Monitoring Sentry Error logging StatusPage Status page