Skip to content
Snippets Groups Projects
Commit 6c5c9bca authored by Walter Lampl's avatar Walter Lampl
Browse files

Merge branch 'acccache_exc' into 'master'

AccumulatorCache: fix cache statistics if exception is thrown

See merge request atlas/athena!48336
parents 5b668b4a 1d458304
No related branches found
No related tags found
No related merge requests found
......@@ -110,6 +110,7 @@ class AccumulatorDecorator:
return None
def __call__(self , *args , **kwargs):
cacheHit = None
try:
t0 = time.perf_counter()
res, cacheHit = self._callImpl(*args, **kwargs)
......
......@@ -52,6 +52,19 @@ class TestCache(unittest.TestCase):
info = fac.getInfo()
self.assertEqual(info["hits"] , 1)
def test_exception(self):
"""Test cache when function throws exception."""
class MyException(BaseException):
pass
@AccumulatorCache
def throw():
raise MyException()
# Make sure no other exception is thrown by decorator itself
self.assertRaises(MyException, throw)
def test_cache_limit(self):
"""Test cache limits."""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment