diff options
| author | Aurélien Bompard <aurelien@bompard.org> | 2013-11-28 13:41:17 +0100 |
|---|---|---|
| committer | Aurélien Bompard <aurelien@bompard.org> | 2013-11-28 13:41:17 +0100 |
| commit | 1c3614f2221af72f94f7424bc5eebdc05ed1311e (patch) | |
| tree | 232fc2ac4269682865edaf110188ad45939ef17d | |
| parent | ff2881ed29ad001959ac04b0fd906bfbfcef13d8 (diff) | |
| download | kittystore-1c3614f2221af72f94f7424bc5eebdc05ed1311e.tar.gz kittystore-1c3614f2221af72f94f7424bc5eebdc05ed1311e.tar.xz kittystore-1c3614f2221af72f94f7424bc5eebdc05ed1311e.zip | |
Nicer logging when refreshing the cache
| -rw-r--r-- | kittystore/caching/__init__.py | 7 | ||||
| -rw-r--r-- | kittystore/caching/email.py | 4 | ||||
| -rw-r--r-- | kittystore/caching/mlist.py | 4 | ||||
| -rw-r--r-- | kittystore/caching/thread.py | 8 |
4 files changed, 17 insertions, 6 deletions
diff --git a/kittystore/caching/__init__.py b/kittystore/caching/__init__.py index f2e33c8..1c7bfb8 100644 --- a/kittystore/caching/__init__.py +++ b/kittystore/caching/__init__.py @@ -17,9 +17,14 @@ from urllib2 import HTTPError from pkg_resources import resource_listdir import mailmanclient +import logging +logger = logging.getLogger(__name__) + class CachedValue(object): + start_msg = __doc__ + def on_new_message(self, store, mlist, message): """A new message has been added to the list""" pass @@ -80,4 +85,6 @@ class CacheManager(object): def refresh(self, store): for cval in self._cached_values: + if cval.start_msg: + logger.info(cval.start_msg) cval.refresh(store) diff --git a/kittystore/caching/email.py b/kittystore/caching/email.py index 261685a..6e44b5f 100644 --- a/kittystore/caching/email.py +++ b/kittystore/caching/email.py @@ -15,6 +15,7 @@ logger = logging.getLogger(__name__) class MailmanUser(CachedValue): + start_msg = "Getting missing email user ids from Mailman" _mm_client = None _user_id_cache = {} @@ -62,10 +63,9 @@ class MailmanUser(CachedValue): def refresh(self, store): # There can be millions of emails, break into smaller chuncks to avoid # hogging up the memory - logger.info("Getting missing email user ids from Mailman") + buffer_size = 50000 # XXX: Storm-specific from kittystore.storm.model import Email - buffer_size = 50000 prev_count = store.db.find(Email, Email.user_id == None).count() try: while True: diff --git a/kittystore/caching/mlist.py b/kittystore/caching/mlist.py index 16e993d..93dc929 100644 --- a/kittystore/caching/mlist.py +++ b/kittystore/caching/mlist.py @@ -35,6 +35,8 @@ class CompatibleMList(object): class ListProperties(CachedValue): + start_msg = "Refreshing list properties from Mailman" + def on_new_message(self, store, mlist, message): l = store.get_list(mlist.fqdn_listname) if isinstance(mlist, mailmanclient._client._List): @@ -64,6 +66,8 @@ class RecentListActivity(CachedValue): Refresh the recent_participants_count and recent_threads_count properties. """ + start_msg = "Computing recent list activity" + def on_new_message(self, store, mlist, message): l = store.get_list(mlist.fqdn_listname) begin_date = l.get_recent_dates()[0] diff --git a/kittystore/caching/thread.py b/kittystore/caching/thread.py index 4862aa8..5e7fa29 100644 --- a/kittystore/caching/thread.py +++ b/kittystore/caching/thread.py @@ -5,13 +5,12 @@ Cached values concerning threads from kittystore.caching import CachedValue -import logging -logger = logging.getLogger(__name__) - class ThreadStats(CachedValue): """Number of emails and number of participants""" + start_msg = "Computing thread statistics" + def on_new_message(self, store, mlist, message): if message.thread.emails_count is None: message.thread.emails_count = 1 @@ -21,7 +20,6 @@ class ThreadStats(CachedValue): len(message.thread.participants) def refresh(self, store): - logger.info("Refreshing thread statistics") # XXX: Storm-specific from kittystore.storm.model import Thread for num, thread in enumerate(store.db.find(Thread)): @@ -34,6 +32,8 @@ class ThreadStats(CachedValue): class ThreadSubject(CachedValue): + start_msg = "Refreshing thread subjects" + def on_new_thread(self, store, mlist, thread): thread.subject = thread.starting_email.subject |
