diff options
Diffstat (limited to 'statsd/client')
-rw-r--r-- | statsd/client/base.py | 10 | ||||
-rw-r--r-- | statsd/client/timer.py | 2 | ||||
-rw-r--r-- | statsd/client/udp.py | 4 |
3 files changed, 8 insertions, 8 deletions
diff --git a/statsd/client/base.py b/statsd/client/base.py index 61dcf18..4fbbe5c 100644 --- a/statsd/client/base.py +++ b/statsd/client/base.py @@ -5,7 +5,7 @@ from datetime import timedelta from .timer import Timer -class StatsClientBase(object): +class StatsClientBase: """A Base class for various statsd clients.""" def close(self): @@ -51,7 +51,7 @@ class StatsClientBase(object): pipe._send_stat(stat, '%s|g' % value, 1) else: prefix = '+' if delta and value >= 0 else '' - self._send_stat(stat, '%s%s|g' % (prefix, value), rate) + self._send_stat(stat, '{}{}|g'.format(prefix, value), rate) def set(self, stat, value, rate=1): """Set a set value.""" @@ -64,12 +64,12 @@ class StatsClientBase(object): if rate < 1: if random.random() > rate: return - value = '%s|@%s' % (value, rate) + value = '{}|@{}'.format(value, rate) if self._prefix: - stat = '%s.%s' % (self._prefix, stat) + stat = '{}.{}'.format(self._prefix, stat) - return '%s:%s' % (stat, value) + return '{}:{}'.format(stat, value) def _after(self, data): if data: diff --git a/statsd/client/timer.py b/statsd/client/timer.py index 453197e..5354a47 100644 --- a/statsd/client/timer.py +++ b/statsd/client/timer.py @@ -10,7 +10,7 @@ def safe_wraps(wrapper, *args, **kwargs): return functools.wraps(wrapper, *args, **kwargs) -class Timer(object): +class Timer: """A context manager/decorator for statsd.timing().""" def __init__(self, client, stat, rate=1): diff --git a/statsd/client/udp.py b/statsd/client/udp.py index 4e44d5c..ec10fc7 100644 --- a/statsd/client/udp.py +++ b/statsd/client/udp.py @@ -6,7 +6,7 @@ from .base import StatsClientBase, PipelineBase class Pipeline(PipelineBase): def __init__(self, client): - super(Pipeline, self).__init__(client) + super().__init__(client) self._maxudpsize = client._maxudpsize def _send(self): @@ -40,7 +40,7 @@ class StatsClient(StatsClientBase): """Send data to statsd.""" try: self._sock.sendto(data.encode('ascii'), self._addr) - except (socket.error, RuntimeError): + except (OSError, RuntimeError): # No time for love, Dr. Jones! pass |