Mercurial > piecrust2
diff piecrust/environment.py @ 412:a1567766c83c
internal: Allow re-registering performance timers.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Sat, 20 Jun 2015 19:15:57 -0700 |
parents | e7b865f8f335 |
children | ff6cc43fb40c |
line wrap: on
line diff
--- a/piecrust/environment.py Fri Jun 12 17:09:19 2015 -0700 +++ b/piecrust/environment.py Sat Jun 20 19:15:57 2015 -0700 @@ -137,7 +137,10 @@ self.base_asset_url_format = '%uri%' self._onSubCacheDirChanged(app) - def registerTimer(self, category): + def registerTimer(self, category, *, raise_if_registered=True): + if raise_if_registered and category in self._timers: + raise Exception("Timer '%s' has already been registered." % + category) self._timers[category] = 0 @contextlib.contextmanager