Generate task name from name/module pair.
(app, name, module_name)
| 120 | |
| 121 | |
| 122 | def gen_task_name(app, name, module_name): |
| 123 | """Generate task name from name/module pair.""" |
| 124 | module_name = module_name or '__main__' |
| 125 | try: |
| 126 | module = sys.modules[module_name] |
| 127 | except KeyError: |
| 128 | # Fix for manage.py shell_plus (Issue #366) |
| 129 | module = None |
| 130 | |
| 131 | if module is not None: |
| 132 | module_name = module.__name__ |
| 133 | # - If the task module is used as the __main__ script |
| 134 | # - we need to rewrite the module part of the task name |
| 135 | # - to match App.main. |
| 136 | if MP_MAIN_FILE and module.__file__ == MP_MAIN_FILE: |
| 137 | # - see comment about :envvar:`MP_MAIN_FILE` above. |
| 138 | module_name = '__main__' |
| 139 | if module_name == '__main__' and app.main: |
| 140 | return '.'.join([app.main, name]) |
| 141 | return '.'.join(p for p in (module_name, name) if p) |
| 142 | |
| 143 | |
| 144 | def load_extension_class_names(namespace): |