omab/django-social-auth — pull request #206 by stephenmcd (2011-12-24 20:39:58+00:00)
Title: Race condition in backend loading

I've refactored the backend loading to avoid the race condition described in #204

I've kept `social_auth.backends.BACKENDS` in place, but it is initially empty and is used as a cache in `social_auth.backends.BACKENDS`. If the backend is not found in the cache, each of the modules implied in the `AUTHENTICATION_BACKENDS` setting is imported and checked for a `BACKENDS` dict as is already the case with current backends. If found, the backend is then added to `social_auth.backends.BACKENDS` for subsequent retrieval.

So the loading occurs one-time on first lookup, rather than at import time. This avoids the race condition and should be backwards compatible as it doesn't change any semantics, apart from making the `SOCIAL_AUTH_IMPORT_BACKENDS` setting redundant. I've removed references to this setting from the docs, and added a deprecation warning that is given if this setting is defined.

I've also removed the duplicate `social_auth` package from the example app, and modified its settings module to use the proper `social_auth` package up one directory.