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!

Decorator that pings URLs before and after executing the wrapped obj.

Project Description

babis

Decorator that pings URLs before and after executing the wrapped obj. Useful to monitor cron jobs with services like Dead Man’s Snitch or HealthChecks.io.

Features

  • Pre and After run pings
  • Custom user agent
  • Silent failures
  • Rate limiting

Usage

Ping after successful execution:

@babis.decorator(ping_after='http://healthchecks.io/XXX')
def cron_job():
  pass

Some services support pre and after hooks to measure the running time:

@babis.decorator(ping_before='http://healthchecks.io/XXX', ping_after='http://healthchecks.io/XXX')
def measured_cron_job():
  pass

You can also send a POST instead of the default GET:

@babis.decorator(ping_before='http://healthchecks.io/XXX', method='post')
def cron_job_with_post():
  pass

And if you don’t care if the ping fails, silence the errors:

@babis.decorator(ping_before='http://healthchecks.io/XXX', silent_failures=True)
def cron_job_silent_failure():
  pass

You can also rate limit the number of pings send to play nice with third party services, let’s say to at most 1 call in 5 minutes:

@babis.decorator(ping_after='http://healthchecks.io/XXX', rate='1/5m')
def cron_job_rate_limited():
  pass

or at most 24 calls per day:

@babis.decorator(ping_after='http://healthchecks.io/XXX', rate='24/1d')
def cron_job_rate_limited():
  pass

Note that if you defined both ping_after and ping_before URLs then each call counts for two hits by the rate limiter.

Credits

This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.

History

0.2.0 (2017-05-24)

  • Add rate limiting.

0.1.0 (2016-08-23)

  • First release on PyPI.
Release History

Release History

This version
History Node

0.2.0

History Node

0.1.0

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
babis-0.2.0-py2.py3-none-any.whl (5.3 kB) Copy SHA256 Checksum SHA256 py2.py3 Wheel May 24, 2017
babis-0.2.0.tar.gz (7.2 kB) Copy SHA256 Checksum SHA256 Source May 24, 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