Python HTTP requests on steroids
request-session is an HTTP library built on top of
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.
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.
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
- Retry: It is possible to configure a retry in case of request failure.
- Logs: Result of the request can also be logged to
- Metrics: On each call you make to
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).
RequestSessioncan 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.
How to run test
To run all tests you just need to run the command
Note that tox doesn't know when you change the
requirements.txtand won't automatically install new dependencies for test runs. Run
pip install tox-batteryto install a plugin which fixes this silliness.
Release history Release notifications | RSS feed
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|Filename, size||File type||Python version||Upload date||Hashes|
|Filename, size request_session-0.11.0-py3-none-any.whl (13.4 kB)||File type Wheel||Python version py3||Upload date||Hashes View|
|Filename, size request_session-0.11.0.tar.gz (38.3 kB)||File type Source||Python version None||Upload date||Hashes View|
Hashes for request_session-0.11.0-py3-none-any.whl