你正在阅读 Celery 3.1 的文档。开发版本文档见: 此处.
Utilities related to importing modules and symbols by name.
Instantiate class by name.
See symbol_by_name().
Get symbol by qualified name.
The name should be the full dot-separated path to the class:
modulename.ClassName
Example:
celery.concurrency.processes.TaskPool
^- class name
or using ‘:’ to separate module and symbol:
celery.concurrency.processes:TaskPool
If aliases is provided, a dict containing short name/long name mappings, the name is looked up in the aliases first.
Examples:
>>> symbol_by_name('celery.concurrency.processes.TaskPool') <class 'celery.concurrency.processes.TaskPool'>>>> symbol_by_name('default', { ... 'default': 'celery.concurrency.processes.TaskPool'}) <class 'celery.concurrency.processes.TaskPool'># Does not try to look up non-string names. >>> from celery.concurrency.processes import TaskPool >>> symbol_by_name(TaskPool) is TaskPool True
Version of imp.find_module() supporting dots.