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
Documentation
Installing
pip install httsleep
Testing
pip install -e . pip install -r test-requirements.txt py.test
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
Built Distribution
File details
Details for the file httsleep-0.3.1.tar.gz
.
File metadata
- Download URL: httsleep-0.3.1.tar.gz
- Upload date:
- Size: 24.8 kB
- Tags: Source
- Uploaded using 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
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 90f60e1ba8a14ead1d18f21d5d51c609bac4b2bdba86b852445b53decb0542e1 |
|
MD5 | 442db8e275508522efe0140b4a51ba4a |
|
BLAKE2b-256 | bde27b24f78b29e6fb7d0f611f9be8cd62b49c46f545487126af7588d838033f |
File details
Details for the file httsleep-0.3.1-py2.py3-none-any.whl
.
File metadata
- Download URL: httsleep-0.3.1-py2.py3-none-any.whl
- Upload date:
- Size: 6.9 kB
- Tags: Python 2, Python 3
- Uploaded using 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
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 83ba1e71a433dd473afd8276cf72bc2edb612b71dfdfb3ec66e6cd7ab40ed2bd |
|
MD5 | 2bd5596af354f75963f08e376db136f8 |
|
BLAKE2b-256 | b12a987a71e1034ec25405cc01ca689d9ef859179d37eabe8a2e4c0950978ec2 |