@contextmanager
def isolate_lru_cache(lru_cache_object):
 lru_cache_object.cache_clear()
 try:
  (yield)
 finally:
  lru_cache_object.cache_clear()

@ contextmanager def isolate_lru_cache ( lru_cache_object ) : lru_cache_object . cache_clear ( ) try : ( yield ) finally : lru_cache_object . cache_clear ( )
clear the cache of an lru cache object on entering and exiting .