Skip to main content

A python library for polling HTTP endpoints - batteries included!

Project description

# httsleep

[![Build Status](https://travis-ci.org/kopf/httsleep.svg?branch=master)](https://travis-ci.org/kopf/httsleep)

[![Coverage Status](https://coveralls.io/repos/github/kopf/httsleep/badge.svg?branch=master)](https://coveralls.io/github/kopf/httsleep?branch=master)

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}
]
response = httsleep(
'http://myendpoint/jobs/1', until, alarms=alarms,
max_retries=20)
```

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 error 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.1.2.tar.gz (22.4 kB view hashes)

Uploaded Source

Supported by

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