def get_backend_cls(backend, loader=None): """Get backend class by name/alias""" loader = loader or current_app.loader if backend not in _backend_cache: aliases = dict(BACKEND_ALIASES, **loader.override_backends) _backend_cache[backend] = get_cls_by_name(backend, aliases) return _backend_cache[backend]
def get_backend_cls(backend, loader=None): """Get backend class by name/alias""" loader = loader or current_app.loader if backend not in _backend_cache: aliases = dict(BACKEND_ALIASES, **loader.override_backends) try: _backend_cache[backend] = get_cls_by_name(backend, aliases) except ValueError, exc: raise ValueError("Unknown result backend: %r. " "Did you spell it correctly? (%s)" % (backend, exc))
def config_from_object(self, obj, silent=False): if isinstance(obj, basestring): try: obj = get_cls_by_name(obj, imp=self.import_from_cwd) except (ImportError, AttributeError): if silent: return False raise if not hasattr(obj, "__getitem__"): obj = DictAttribute(obj) self._conf = obj return True
def find_symbol(origin, sym): """Find symbol in module relative by ``origin``. E.g. if ``origin`` is an object in the module ``package.foo``, then:: >>> find_symbol(origin, '.bar.my_symbol') will return the object ``my_symbol`` from module ``package.bar``. """ return get_cls_by_name(sym, package=find_package(getattr(origin, '__module__', None or origin.__class__.__module__)))
def find_symbol(origin, sym): """Find symbol in module relative by ``origin``. E.g. if ``origin`` is an object in the module ``package.foo``, then:: >>> find_symbol(origin, '.bar.my_symbol') will return the object ``my_symbol`` from module ``package.bar``. """ return get_cls_by_name(sym, package=find_package( getattr(origin, '__module__', None or origin.__class__.__module__)))
def test_get_cls_by_name__instance_returns_instance(self): instance = object() self.assertIs(utils.get_cls_by_name(instance), instance)
def get_cls_by_name(self, name): from celery.utils import get_cls_by_name, import_from_cwd return get_cls_by_name(name, imp=import_from_cwd)
def get_backend_cls(backend): """Get backend class by name/alias""" if backend not in _backend_cache: aliases = dict(BACKEND_ALIASES, **current_loader().override_backends) _backend_cache[backend] = get_cls_by_name(backend, aliases) return _backend_cache[backend]
def get_backend_cls(backend): """Get backend class by name/alias""" if backend not in _backend_cache: _backend_cache[backend] = get_cls_by_name(backend, BACKEND_ALIASES) return _backend_cache[backend]
def get_loader_cls(loader): """Get loader class by name/alias""" return get_cls_by_name(loader, LOADER_ALIASES)
def get_implementation(cls): return get_cls_by_name(cls, ALIASES)
def loader(self): return get_cls_by_name('loader.NodeLoader', imp = import_from_cwd)(app = self)
def get_backend_cls(backend): if backend not in _backend_cache: _backend_cache[backend] = get_cls_by_name(backend, BACKEND_ALIASES) return _backend_cache[backend]
def instance_dir(self): return get_cls_by_name('cyme.conf.CYME_INSTANCE_DIR')
def get_result(self): if not self._result: from celery.utils import get_cls_by_name Task = get_cls_by_name(self.task_name) self._result = Task.AsyncResult(self.task_id) return self._result