MCPcopy
hub / github.com/celery/celery / gen_task_name

Function gen_task_name

celery/utils/imports.py:122–141  ·  view source on GitHub ↗

Generate task name from name/module pair.

(app, name, module_name)

Source from the content-addressed store, hash-verified

120
121
122def 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
144def load_extension_class_names(namespace):

Callers 2

test_no_moduleMethod · 0.90
gen_task_nameMethod · 0.90

Calls 1

joinMethod · 0.45

Tested by 1

test_no_moduleMethod · 0.72