Skip to main content

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

Release files for httsleep 0.3.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for httsleep 0.3.1
File Size Uploaded
httsleep-0.3.1.tar.gz 24.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for httsleep 0.3.1
File Interpreter ABI Platform
httsleep-0.3.1-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 31.6 kB

Release files / httsleep-0.3.1.tar.gz

Download URL httsleep-0.3.1.tar.gz
Size 24.8 kB
Tags Source
SHA-256 checksum
How to use checksums
90f60e1ba8a14ead1d18f21d5d51c609bac4b2bdba86b852445b53decb0542e1
BLAKE2b-256 checksum
How to use checksums
bde27b24f78b29e6fb7d0f611f9be8cd62b49c46f545487126af7588d838033f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.8.1 pkginfo/1.4.1 requests/2.10.0 setuptools/25.1.1 requests-toolbelt/0.7.1 clint/0.5.1 CPython/2.7.10 Darwin/17.7.0

Release files / httsleep-0.3.1-py2.py3-none-any.whl

Download URL httsleep-0.3.1-py2.py3-none-any.whl
Size 6.9 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
83ba1e71a433dd473afd8276cf72bc2edb612b71dfdfb3ec66e6cd7ab40ed2bd
BLAKE2b-256 checksum
How to use checksums
b12a987a71e1034ec25405cc01ca689d9ef859179d37eabe8a2e4c0950978ec2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.8.1 pkginfo/1.4.1 requests/2.10.0 setuptools/25.1.1 requests-toolbelt/0.7.1 clint/0.5.1 CPython/2.7.10 Darwin/17.7.0

Release history Release notifications | RSS feed

This release

0.3.1 This release

2 release files

0.3.0

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.4

1 release file

0.1.3

1 release file

0.1.2

1 release file

0.1.1

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page