Option to ignore exceptions (e.g. ConnectionError)

Issue #72 new
Mihnea Dobrescu-Balaur
created an issue

It would be useful to have a parameter for when configuring a region such that exceptions are silenced. Since we are talking about a cache, the application should still run even if the cache dies - putting try except everywhere in the code where one uses caching is too much. A global flag that decides to silence the exceptions or not would do this job.

Comments (4)

  1. Mihnea Dobrescu-Balaur reporter

    Using proxybackend, I'd have to override every method that I care about with the try/except logic, correct? Or is there a way to do this in one single place (other than doing some __getattribute__ magic)?

  2. Michael Bayer repo owner

    it's six method calls. So cleanest is probably just to implement them. However, short of __getattribute__, there is, class decorator, metaclass, etc., each of which iterate through dir(cls) and apply a decorator. Many ways to go.

    The reason this should be custom is b.c. squashing exceptions is a controversial affair. which exceptions are ignored, and when? how are they logged? are there warnings? are there steps to take to fall back to some other cache when an exception is raised? etc. the actual problem domain here is much more open ended than a simple flag could do justice. Apps that really need caching will often fall over immediately from load if their cache isn't up, so the "fall back to no caching at all" use case is not so common.

  3. Log in to comment