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 details)
Built Distribution
File details
Details for the file request-miner-0.0.1.tar.gz
.
File metadata
- Download URL: request-miner-0.0.1.tar.gz
- Upload date:
- Size: 2.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 84a959a12fbe25b39973890eeae5987dc551e3b8da9a3c4bc020f0749355806c |
|
MD5 | 6d95254a8f6678c2532317b8181be982 |
|
BLAKE2b-256 | cad28ec4be266e79930ba75f77f74fef0d8880e55fda1aa9a461dbc7dce261e8 |
File details
Details for the file request_miner-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: request_miner-0.0.1-py3-none-any.whl
- Upload date:
- Size: 2.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f248d329eb9f59a115aa8a82c6d8d3d22e0eb8a47cfb73c550ef3c3f61ad86c8 |
|
MD5 | d0573f74968e7a32b39c5e09efb62e5f |
|
BLAKE2b-256 | 52f973f505c968384c37d7750259a58f6add69aa6bfb5eba276b0f78a48101cb |