Skip to main content

request-session

Versions 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.

Metadata

Release files for request-session 0.9.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for request-session 0.9.4
File Size Uploaded Provenance Actions
request_session-0.9.4.tar.gz 6.6 MB Without provenance Details for request_session-0.9.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for request-session 0.9.4
File Interpreter ABI Platform Actions
request_session-0.9.4-py3-none-any.whl Python 3 none any Details for request_session-0.9.4-py3-none-any.whl

Total release size: 6.7 MB

Release files / request_session-0.9.4.tar.gz

Download URL request_session-0.9.4.tar.gz
Size 6.6 MB
Tags Source
SHA-256 checksum
How to use checksums
98f5e61e0b0758473ec262c9bb38a2f376b159f6ad2831c554ae1fc797971ff6
BLAKE2b-256 checksum
How to use checksums
233f299c38979cef360bd513c9b2a28230154aa70b2bc851a9e9ec5d92323176
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / request_session-0.9.4-py3-none-any.whl

Download URL request_session-0.9.4-py3-none-any.whl
Size 29.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
af19ce0773c72860bafb5b6823344c79c38c43300718f323ca9d7bb3c9dfefd7
BLAKE2b-256 checksum
How to use checksums
e462ee0357b3fac886b35a6c213b48566f5ee0eaa72ac2c85c9dc1e2c102c73c
Upload date
Uploaded using Trusted Publishing?
What is 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

Security for request-session 0.9.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page