# HG changeset patch # User btimby # Date 1328412499 0 # Node ID d4563cb0376c8b0cb207e28422e07e73cc0abb13 # Parent 2b46eceda739921c2ef9d034ea86729bc2c6722e Handle importing valid module name as backend when that module is NOT a backend. diff -r 2b46eceda739 -r d4563cb0376c queues/__init__.py --- a/queues/__init__.py Sun Feb 05 03:10:46 2012 +0000 +++ b/queues/__init__.py Sun Feb 05 03:28:19 2012 +0000 @@ -56,3 +56,8 @@ queues = __import__(BACKEND, {}, {}, ['']) except ImportError: raise InvalidBackend("Unable to import QUEUE BACKEND '%s'" % BACKEND) + # Check that this is really a queues backend, not just some other random + # module. + from .backends.base import BaseQueue + if not getattr(queues, 'Queue', None) in BaseQueue.__subclasses__(): + raise InvalidBackend("Unable to import QUEUE_BACKEND '%s' does not appear to be valid." % BACKEND) diff -r 2b46eceda739 -r d4563cb0376c queues/backends/__init__.py --- a/queues/backends/__init__.py Sun Feb 05 03:10:46 2012 +0000 +++ b/queues/backends/__init__.py Sun Feb 05 03:28:19 2012 +0000 @@ -25,3 +25,6 @@ backend = __import__(BACKEND, {}, {}, ['']) except ImportError: raise InvalidBackend("Unable to import QUEUE BACKEND '%s'" % BACKEND) + from .base import BaseQueue + if not getattr(backend, 'Queue', None) in BaseQueue.__subclasses__(): + raise InvalidBackend("Unable to import QUEUE BACKEND '%s' does not appear to be valid." % BACKEND)