Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kopf/httsleep
A python library for polling HTTP endpoints - batteries included!
https://github.com/kopf/httsleep
http poll polling python
Last synced: 3 months ago
JSON representation
A python library for polling HTTP endpoints - batteries included!
- Host: GitHub
- URL: https://github.com/kopf/httsleep
- Owner: kopf
- License: apache-2.0
- Created: 2016-07-29T15:42:11.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-11-04T15:19:10.000Z (almost 6 years ago)
- Last Synced: 2024-06-23T05:07:30.839Z (4 months ago)
- Topics: http, poll, polling, python
- Language: Python
- Homepage:
- Size: 85.9 KB
- Stars: 48
- Watchers: 5
- Forks: 3
- Open Issues: 4
-
Metadata Files:
- Readme: README.rst
- Changelog: CHANGELOG.rst
- License: LICENSE
Awesome Lists containing this project
- starred-awesome - httsleep - A python library for polling HTTP endpoints - batteries included! (Python)
README
httsleep
========|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.alarmTranslated 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 404Documentation
-------------http://httsleep.readthedocs.io/
Installing
----------::
pip install httsleep
Testing
-------::
pip install -e .
pip install -r test-requirements.txt
py.test.. |Build Status| image:: https://travis-ci.org/kopf/httsleep.svg?branch=master
:target: https://travis-ci.org/kopf/httsleep
.. |Coverage Status| image:: https://coveralls.io/repos/github/kopf/httsleep/badge.svg?branch=master
:target: https://coveralls.io/github/kopf/httsleep?branch=master