A simple requests wrapper with backoff.
Project description
Request Miner
A tool that enables you to automatically request and retry failing requests for a certain amount of times.
This tool is built on top of: requests
and backoff
, which this package relies on.
Installation
pip install request-miner
Usage
To create a request without passing a session:
from request_miner import mine
from requests.exceptions import RequestException
get_req = mine(method="GET", url="https://www.google.com")
post_req = mine(
method="POST",
url="https://www.google.com",
json={"key": "value"},
backoff_type = "expo", # default is constant, but you can override with existing backoff functions or your own
max_tries = 3, # max tries of a single request
max_time = 10, # max time of a request
exception = RequestException, # exception types that can be handled
raise_on_giveup = True # if you want to raise the exception on giveup
) # This request will fail
To create a prepared request with a session:
import requests
from requests import Request, Session
from request_miner import process_request
from requests.exceptions import RequestException
session = requests.Session()
get_req = Request(method="GET", url="https://www.google.com").prepare()
process_request(
get_req,
session,
backoff_type = "expo", # default is constant, but you can override with existing backoff functions or your own
max_tries = 3, # max tries of a single request
max_time = 10, # max time of a request
exception = RequestException, # exception types that can be handled
raise_on_giveup = True # if you want to raise the exception on giveup
)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
request-miner-0.0.1.tar.gz
(2.5 kB
view hashes)
Built Distribution
Close
Hashes for request_miner-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f248d329eb9f59a115aa8a82c6d8d3d22e0eb8a47cfb73c550ef3c3f61ad86c8 |
|
MD5 | d0573f74968e7a32b39c5e09efb62e5f |
|
BLAKE2b-256 | 52f973f505c968384c37d7750259a58f6add69aa6bfb5eba276b0f78a48101cb |