toastdriven/django-haystack — pull request #958 by craigds (2014-02-27 00:42:26+00:00)
Title: Fix concurrency issues in UnifiedIndex.build()

We were getting this error a lot when under load in a multithreaded
wsgi environment:

Model '%s' has more than one 'SearchIndex`` handling it.

Turns out the connections in haystack.connections and the
UnifiedIndex instance were stored globally. However there is a race
condition in UnifiedIndex.build() when multiple threads both build()
at once, resulting in the above error.

Best fix is to never share the same engine or UnifiedIndex across
multiple threads. This commit does that.