diff -r 2b049c9fcec5 -r b640ef6ad633 cubicweb/statsd_logger.py --- a/cubicweb/statsd_logger.py Wed Dec 13 01:23:39 2017 +0100 +++ b/cubicweb/statsd_logger.py Mon Oct 16 12:10:19 2017 +0200 @@ -47,7 +47,7 @@ There is also a decorator (``statsd_timeit``) that may be used to measure and send to the statsd_ server the time passed in a function or a method and the number of calls. It will send a message like:: - + .:|ms\n.:1|c\n @@ -56,7 +56,6 @@ """ - import time import socket @@ -112,10 +111,11 @@ @property def __doc__(self): return self.callable.__doc__ + @property def __name__(self): return self.callable.__name__ - + def __call__(self, *args, **kw): if _address is None: return self.callable(*args, **kw) @@ -123,13 +123,14 @@ try: return self.callable(*args, **kw) finally: - dt = 1000*(time.time()-t0) - msg = '{0}.{1}:{2:.4f}|ms\n{0}.{1}:1|c\n'.format(_bucket, self.__name__, dt) + dt = 1000 * (time.time() - t0) + msg = '{0}.{1}:{2:.4f}|ms\n{0}.{1}:1|c\n'.format( + _bucket, self.__name__, dt) _socket.sendto(msg, _address) - + def __get__(self, obj, objtype): """Support instance methods.""" - if obj is None: # class method or some already wrapped method + if obj is None: # class method or some already wrapped method return self import functools return functools.partial(self.__call__, obj)