Here's an example method that's inside a Python Class:
def publish_aggregate_account_group_stats(self, account_group_token):
message = {
"type": "metrics-aggregate-account-group-stats",
"accountGroupToken": account_group_token
}
try:
self._get_writer().write(message)
except:
self._put_cache(message)
There is a handful of methods in my class that all run the try/except
, that I think could be DRYed up or cleaned up by simply creating a decorator that handles that for me. I'm just unsure how the decorator would look/work by accessing self
.