Skip to main content

A python network request library that will not throw exceptions

Project description

reqe

A python network request library that will not throw exceptions

Table of Contents

Background

When timeout, network connection error, server error, etc., requests will raise the exception, there will be a lot of try ... except ... in the code.

Under the above problems, I developed a reqe based on the requests library, which is as simple as requests

Install

  • source code

git clone git@github.com:ophlr/reqe.git
  • pip

pip install reqe

Usage

import reqe

# use default setting, it can be used like request
response = reqe.get("https://www.baidu.com")
if response:
    print(response)

# specify the params that you like
# retries: How many retries, If you don’t want to resend the request, you can set retries to 0
# delay: time between two requests
# backoff: delay = delay * backoff
response = reqe.get("https://www.google.com", retries=3, delay=3, backoff=2)
# when `requests` raises an exception, `reqe` will catch it and let the response be None
if response:
    print(response)


# how to use reqe with session
session = reqe.session()
response = session.get("https://www.google.com", retries=1, delay=3, backoff=2)
print(response)

Reference

License

Apache 2.0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

reqe-2020.9.17.175617-py3-none-any.whl (9.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page