Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!

A python library for polling HTTP endpoints - batteries included!

Project Description

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

Installing

pip install httsleep

Testing

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

Release History

This version
History Node

0.2.2

History Node

0.2.1

History Node

0.2.0

History Node

0.1.4

History Node

0.1.3

History Node

0.1.2

History Node

0.1.1

Download Files

Download Files

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

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
httsleep-0.2.2-py2.py3-none-any.whl (7.0 kB) Copy SHA256 Checksum SHA256 py2.py3 Wheel Jul 11, 2017
httsleep-0.2.2.tar.gz (23.2 kB) Copy SHA256 Checksum SHA256 Source Jul 11, 2017

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting