wolph / python-statsd

Python Client for the Etsy NodeJS Statsd Server
http://readthedocs.org/docs/python-statsd/en/latest/
BSD 3-Clause "New" or "Revised" License
110 stars 39 forks source link

Add a contextmanager to Timer #29

Closed lclarkmichalek closed 10 years ago

lclarkmichalek commented 10 years ago

This allows for timing of arbitrary blocks of code:

>>> with timer.time("foobar"):
...    thing_to_be_timed()
...    etc++
...
coveralls commented 10 years ago

Coverage Status

Coverage decreased (-0.48%) when pulling 2133c4cb6ab1a0809ca8cc3c9c56ae314b271a6c on bluepeppers:contextmanager into 428aa3eff653784333ae9e5700a0f5ddf8396c21 on WoLpH:master.

lclarkmichalek commented 10 years ago

Looks like the build failed on python 3 because this branch doesn't contain my python 3 fixes. I can rebase if you like (the python 2 branches pass, so I don't think it's a major problem)

wolph commented 10 years ago

Don't worry about it :)

Thanks for the patch, it seems I have this part only in the django-statsd code... thought I had a contextmanager like this in both. Awesome patch anyhow!

lclarkmichalek commented 10 years ago

Thanks for merging promptly :+1: Could you bump the version so I can get a valid python3 version off PyPi