Handle multiple write-enabled haystack routers #33
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
It's possible for a project to have multiple
HAYSTACK_ROUTERS
set up that will handle writes to different search backends:http://django-haystack.readthedocs.org/en/latest/settings.html#haystack-routers
Currently in celery-haystack, the signal handler returns after finding the first writable backend, which this commit fixes.
You can also see here in haystack's default signal handler that the behaviour is different - it doesn't return after finding the first writable backend:
https://github.com/toastdriven/django-haystack/blob/f80cb9f92db1bf080ea5c1bc7e7bff34b1b8ce72/haystack/signals.py#L38-L51
I'm not sure if the early return in celery-haystack is masking another bug where the same task was being enqueued multiple times, or if it was just a minor optimisation - hopefully the latter, but if the former, then this one-line fix is probably insufficient.
Thanks!