Skip to main content

No project description provided

Project description

request_session

Code style: black

request_session is an HTTP library built on top of requests that makes your live easier by retrying whenever a request fails, logs the results or even sends metrics and traces to DataDogHQ. RequestSession also measures the time of the request.

Use RequestSession to create a client module for accessing a group of resources served on a common endpoint with default values valid for all or most of the calls you need to make. For your convenience, some defaults are already provided.

Usage

To install request_session, use pip:

pip install request_session
from request_session import RequestSession

client = RequestSession(
    host="https://jobs.kiwi.com",
    max_retries=4,          # how many times to retry in case server error occurs
    raise_for_status=True,  # raise an exception if failed on every attempt
)

response = client.get(
    path="/",
    sleep_before_repeat=1,      # how many seconds to wait untill next try  
    request_category="jobs",    # what to log to stdout/stderr
)

Benefits of using RequestSession

  • Retry: It is possible to configure a retry in case of request failure.
  • Logs: Result of the request can also be logged to stdout.
  • Metrics: On each call you make to GET, POST, PUT, PATCH, and DELETE` methods, several metrics are sent to your datadog client - duration of the request, how many requests were sent, outcome of the request (a DataDog integration is needed).
  • Tracing: RequestSession can send tracing info to DataDog (an APM integration is needed).

You can find more details about RequestSession's benefits and examples in the official documentation.

Contributing

Create a merge request and assign it to Josef Podaný for review.

How to run test

To run all tests you just need to run the command tox.

Note that tox doesn't know when you change the requirements.txt and won't automatically install new dependencies for test runs. Run pip install tox-battery to install a plugin which fixes this silliness.

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

request_session-0.9.0.tar.gz (6.6 MB view details)

Uploaded Source

Built Distribution

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

request_session-0.9.0-py3-none-any.whl (28.8 kB view details)

Uploaded Python 3

File details

Details for the file request_session-0.9.0.tar.gz.

File metadata

  • Download URL: request_session-0.9.0.tar.gz
  • Upload date:
  • Size: 6.6 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.6.5

File hashes

Hashes for request_session-0.9.0.tar.gz
Algorithm Hash digest
SHA256 1732247d7d457dfa4b499fb5a06fd74a593be4a7d0cae19bcf9981a304885c3d
MD5 3980e371878e3fe73144c0f3e41efd1e
BLAKE2b-256 5e11f580c72ee8e240cdf0ec0e30d906d34fd8c90206e1d7efd66fba13a60102

See more details on using hashes here.

File details

Details for the file request_session-0.9.0-py3-none-any.whl.

File metadata

  • Download URL: request_session-0.9.0-py3-none-any.whl
  • Upload date:
  • Size: 28.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.6.5

File hashes

Hashes for request_session-0.9.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0ed8bb909587499c2f625f1c55b0cd3349920224a1b36661cc1a1b4458f997ea
MD5 d4a9d475d5018fb91ed503a25df5ba8c
BLAKE2b-256 29c39ff3cb9d639625d0e6a146bbacef2a2d95b92cae67e0f9ebe5ab3b9191b8

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