in fbtftp/base_server.py [0:0]
def __init__(self, server_addr=None, interval=None):
"""
`ServerStats` represents a digest of what happened during the server's
lifetime.
This class exposes a counter interface with get/set/reset methods and
an atomic get-and-reset.
An instance of this class is passed to a periodic function that is
executed by a background thread inside the `BaseServer` object.
See `stats_callback` in the `BaseServer` constructor.
If you use it in a metric publishing callback, remember to use atomic
operations and to reset the counters to have a fresh start. E.g. see
`get_and_reset_all_counters'.
Args:
server_addr (str): the server address, either v4 or v6.
interval (int): stats interval in seconds.
Note:
`server_addr` and `interval` are provided by the `BaseServer`
class. They are not used in this class, they are there for the
programmer's convenience, in case one wants to use them.
"""
self.server_addr = server_addr
self.interval = interval
self.start_time = time.time()
self._counters = collections.Counter()
self._counters_lock = threading.Lock()