def deferred_ratings(): """ This is the deferred ratings table calculation process """ # Disable the in-context cache to save memory # (it doesn't give any speed advantage for this processing) Context.disable_cache() t0 = time.time() try: _create_ratings() except DeadlineExceededError as ex: # Hit deadline: save the stuff we already have and # defer a new task to continue where we left off logging.error(u"Deadline exceeded in ratings, failing permamently") # Normal return prevents this task from being run again raise deferred.PermanentTaskFailure() except Exception as ex: logging.error(u"Exception in ratings, failing permanently: {0}".format(ex)) # Avoid having the task retried raise deferred.PermanentTaskFailure() t1 = time.time() logging.info(u"Ratings calculation finished in {0:.2f} seconds".format(t1 - t0)) StatsModel.log_cache_stats() StatsModel.clear_cache() # Do not maintain the cache in memory between runs
def deferred_ratings(): """ This is the deferred ratings table calculation process """ # Disable the in-context cache to save memory # (it doesn't give any speed advantage for this processing) Context.disable_cache() t0 = time.time() try: _create_ratings() except DeadlineExceededError as ex: # Hit deadline: save the stuff we already have and # defer a new task to continue where we left off logging.error(u"Deadline exceeded in ratings, failing permamently") # Normal return prevents this task from being run again raise deferred.PermanentTaskFailure() except Exception as ex: logging.error( u"Exception in ratings, failing permanently: {0}".format(ex)) # Avoid having the task retried raise deferred.PermanentTaskFailure() t1 = time.time() logging.info(u"Ratings calculation finished in {0:.2f} seconds".format(t1 - t0)) StatsModel.log_cache_stats() StatsModel.clear_cache( ) # Do not maintain the cache in memory between runs
def deferred_ratings(): """ This is the deferred ratings table calculation process """ with Client.get_context() as context: t0 = time.time() try: _create_ratings() except Exception as ex: logging.error("Exception in deferred_ratings: {0!r}".format(ex)) return t1 = time.time() StatsModel.log_cache_stats() # Do not maintain the cache in memory between runs StatsModel.clear_cache() logging.info( "Ratings calculation finished in {0:.2f} seconds".format(t1 - t0))