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

Make timer a context manager by itself. #46

Closed fizyk closed 7 years ago

fizyk commented 7 years ago

This allows the timer to be it;'s own context manager while allowing to send intermediate measurments as well (addressing comment in #39 )

wolph commented 7 years ago

Thanks for the help. It was already possible using the .time() method but I suppose this is just as convenient :)

fizyk commented 7 years ago

Hmm... I was expecting I'd have to fix something, add docstring, becasue that was quickly put up pull request based on our modifications (we subclass Timer class in our project). Or the very least to add some tests.

Anyway, I suppose that's the matter of preferences. With this modifications, you should be safely able to just instantiate the Timer in the with block assign it to a var and use this var in the code block.

wolph commented 7 years ago

I've added some tests and released a new version. Thanks again :)