From 08f0d10a25a7c6a8cf54dd8aacece4ad45f0a818 Mon Sep 17 00:00:00 2001 From: Joshua Harlow Date: Tue, 6 Oct 2015 17:08:48 -0700 Subject: [PATCH] Add useful watcher '__repr__' function When a workers watchers are iterated over and say printed to stderr/stdout the default '__repr__' doesn't provide much value; so instead of the default provide our own that adds slightly more value. Change-Id: I8f82a732ad3d9f0ce0ec5857d5d883b3b5f2ff1d --- futurist/periodics.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/futurist/periodics.py b/futurist/periodics.py index a629b67..eb1b4de 100644 --- a/futurist/periodics.py +++ b/futurist/periodics.py @@ -46,9 +46,21 @@ IMMEDIATE = 'immediate' class Watcher(object): """A **read-only** object representing a periodics callbacks activities.""" + _REPR_MSG_TPL = ("") + def __init__(self, metrics): self._metrics = metrics + def __repr__(self): + return self._REPR_MSG_TPL % dict(ident=id(self), **self._metrics) + @property def runs(self): """How many times the periodic callback has been ran."""