Created
January 4, 2012 17:02
-
-
Save dvogel/1560984 to your computer and use it in GitHub Desktop.
Haystack update_index do_update
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def do_update(backend, index, qs, start, end, total, verbosity=1): | |
# Get a clone of the QuerySet so that the cache doesn't bloat up | |
# in memory. Useful when reindexing large amounts of data. | |
small_cache_qs = qs.all() | |
current_qs = small_cache_qs[start:end] | |
if verbosity >= 2: | |
if os.getpid() == os.getppid(): | |
print " indexed %s - %d of %d." % (start+1, end, total) | |
else: | |
print " indexed %s - %d of %d (by %s)." % (start+1, end, total, os.getpid()) | |
# FIXME: Get the right backend. | |
backend.update(index, current_qs) | |
# Clear out the DB connections queries because it bloats up RAM. | |
reset_queries() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment