From 23a3ba0f1e4ecb76ac916ca7f383995220859ce0 Mon Sep 17 00:00:00 2001 From: Alessio Deiana Date: Fri, 25 May 2012 10:50:45 +0200 Subject: [PATCH] data cacher: deletes cache before refilling it * Deletes data cacher's cache before refilling it. This is useful especially for citation dictionaries. * Removes `touch` work wround from bibrank citation indexer that is not needed anymore. --- modules/bibrank/lib/bibrank_tag_based_indexer.py | 12 ------------ modules/miscutil/lib/data_cacher.py | 4 ++++ 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/modules/bibrank/lib/bibrank_tag_based_indexer.py b/modules/bibrank/lib/bibrank_tag_based_indexer.py index 95a9c186c..57f69b9b8 100644 --- a/modules/bibrank/lib/bibrank_tag_based_indexer.py +++ b/modules/bibrank/lib/bibrank_tag_based_indexer.py @@ -232,18 +232,6 @@ def intoDB(dict, date, rank_method_code): if date: run_sql("UPDATE rnkMETHOD SET last_updated=%s WHERE name=%s", (date, rank_method_code)) - # FIXME: the following is a workaround for the citation indexer - # memory troubles, when Apache WSGI daemon processes may end up - # doubling the memory after citation dictionary is updated; - # therefore let us restart the WSGI daemon application after the - # citation indexer finished, which relieves this problem. The - # restart is done via touching invenio.wsgi file. The proper fix - # for this problem would be strict separation between citation - # indexer updating dicts and citation searcher loading dicts. - if rank_method_code == 'citation': - os.system('touch ' + os.path.join(CFG_PREFIX, 'var', 'www-wsgi', - 'invenio.wsgi')) - def fromDB(rank_method_code): """Get the data for a rank method""" id = run_sql("SELECT id from rnkMETHOD where name=%s", (rank_method_code, )) diff --git a/modules/miscutil/lib/data_cacher.py b/modules/miscutil/lib/data_cacher.py index 7203ce85d..fca278b44 100644 --- a/modules/miscutil/lib/data_cacher.py +++ b/modules/miscutil/lib/data_cacher.py @@ -65,6 +65,10 @@ def create_cache(self): Create and populate cache by calling cache filler. Called on startup and used later during runtime as needed by clients. """ + # We empty the cache first to force freeing of the variable + # this is useful when it is really big like our citations dictionary + self.cache = None + self.cache = self.cache_filler() self.timestamp = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())