Skip to main content
Join the official 2019 Python Developers SurveyStart the survey!

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

Project description


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


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


Ping after successful execution:

def cron_job():

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

@babis.decorator(ping_before='', ping_after='')
def measured_cron_job():

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

@babis.decorator(ping_before='', method='post')
def cron_job_with_post():

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

@babis.decorator(ping_before='', silent_failures=True)
def cron_job_silent_failure():

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='', rate='1/5m')
def cron_job_rate_limited():

or at most 24 calls per day:

@babis.decorator(ping_after='', rate='24/1d')
def cron_job_rate_limited():

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


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


0.2.0 (2017-05-24)

  • Add rate limiting.

0.1.0 (2016-08-23)

  • First release on PyPI.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for babis, version 0.2.2
Filename, size File type Python version Upload date Hashes
Filename, size babis-0.2.2-py2.py3-none-any.whl (4.7 kB) File type Wheel Python version py2.py3 Upload date Hashes View hashes
Filename, size babis-0.2.2.tar.gz (6.9 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page