Skip to main content

A python library for polling HTTP endpoints - batteries included!

Project description

Build Status

Coverage Status

httsleep is a powerful polling library for Python.

Idea

Set your success conditions, set a few alarms, and get polling!

until = {
    'status_code': 200,
    'jsonpath': [{'expression': 'status', 'value': 'OK'}]
}
alarms = [
    {'json': {'status': 'ERROR'}},
    {'jsonpath': [{'expression': 'status', 'value': 'UNKNOWN'},
                  {'expression': 'owner', 'value': 'Chris'}],
    'callback': is_job_really_failing},
    {'status_code': 404}
]
try:
   response = httsleep(
       'http://myendpoint/jobs/1', until, alarms=alarms,
       max_retries=20)
except Alarm as e:
    print "Response was:", e.response
    print "Alarm condition that matched was:", e.alarm

Translated into English, this means:

  • Poll http://myendpoint/jobs/1 – at most 20 times – until

    • it returns a status code of 200

    • AND the status key in its response has the value OK

  • but raise an alarm if

    • the status key has the value ERROR

    • OR the status key has the value UNKNOWN AND the owner key has the value Chris AND the function is_job_really_dying returns True

    • OR the status code is 404

Documentation

http://httsleep.readthedocs.io/

Installing

pip install httsleep

Testing

pip install -e .
pip install -r test-requirements.txt
py.test

Project details


Download files

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

Source Distribution

httsleep-0.3.0.tar.gz (24.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

httsleep-0.3.0-py2.py3-none-any.whl (6.9 kB view details)

Uploaded Python 2Python 3

File details

Details for the file httsleep-0.3.0.tar.gz.

File metadata

  • Download URL: httsleep-0.3.0.tar.gz
  • Upload date:
  • Size: 24.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for httsleep-0.3.0.tar.gz
Algorithm Hash digest
SHA256 837208bf99e3e72cf532d563de5ff5c4d73611ed00f77037b7a41f531f149da1
MD5 949b9b20620c46f7cbf2a8899e9e6d93
BLAKE2b-256 bb3aa87351470df8d3f5a1e7fabe8f1994c314696fd71b32f81e4a7e1b05184f

See more details on using hashes here.

File details

Details for the file httsleep-0.3.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for httsleep-0.3.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 4a3ba5d41463b8e0284007907ae8b8c4c0e402347cae4a094e1343f31b35bae1
MD5 d56243a7c7bd3ca8b1eafd5f75936e4d
BLAKE2b-256 61c062ac70b068d02b6dd2a08dfb1884787e05fccf89349b1af36a2d81f83ccf

See more details on using hashes here.

Supported by

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