Skip to content

Instantly share code, notes, and snippets.

@dvogel
Created January 4, 2012 17:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dvogel/1560984 to your computer and use it in GitHub Desktop.
Save dvogel/1560984 to your computer and use it in GitHub Desktop.
Haystack update_index do_update
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