def load_tasks(app, entry_file=None):
from celery import Task<EOL>tasks_txt = os.path.join(os.path.dirname(entry_file), '<STR_LIT>',<EOL>'<STR_LIT>')<EOL>if not os.path.exists(tasks_txt):<EOL><INDENT>import sys<EOL>print('<STR_LIT>' % tasks_txt)<EOL>sys.exit(-<NUM_LIT:1>)<EOL><DEDENT>class ContextTask(Task):<EOL><INDENT>abstract = True<EOL>def __call__(self, *args, **kwargs):<EOL><INDENT>with app.app_context():<EOL><INDENT>return super().__call__(*args, **kwargs)<EOL><DEDENT><DEDENT><DEDENT>app.celery.config_from_object(app.config, namespace='<STR_LIT>')<EOL>app.celery.Task = ContextTask<EOL>with app.app_context():<EOL><INDENT>with open(tasks_txt, '<STR_LIT:r>') as f:<EOL><INDENT>for line in f:<EOL><INDENT>mod = line.strip('<STR_LIT:\n>')<EOL>if mod:<EOL><INDENT>importlib.import_module(mod + '<STR_LIT>')<EOL><DEDENT>pass<EOL><DEDENT>pass<EOL><DEDENT>pass<EOL><DEDENT>pass<EOL>
装载任务，解决celery无法自动装载的问题