toastdriven/django-haystack — pull request #959 by craigds (2014-02-27 02:33:41+00:00)
Title: Fix concurrency issues.

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.