Python 3.x Django中的芹菜配置,将任务连接到视图

Python 3.x Django中的芹菜配置,将任务连接到视图,python-3.x,celery,django-celery,celery-task,django-1.11,Python 3.x,Celery,Django Celery,Celery Task,Django 1.11,我最近配置了芹菜来运行一些虚拟任务,并在我的Mac上通过终端运行了工人。这一切似乎都相应地运行了一段时间,因为一些文献似乎建议不同的配置场景,但我还是做到了。现在,下一步是通过Django中的my view触发任务。我用的是西芹1.2.26。post2 我的项目结构: /MyApp celery_tasks.py celeryconfig.py __init__.py 我一直在学习一些教程,发现这个和这个,这个对获得芹菜的整体视图非常有帮助 我的脚本是: 芹菜任务.py fr

我最近配置了芹菜来运行一些虚拟任务,并在我的Mac上通过终端运行了工人。这一切似乎都相应地运行了一段时间,因为一些文献似乎建议不同的配置场景,但我还是做到了。现在,下一步是通过Django中的my view触发任务。我用的是西芹1.2.26。post2

我的项目结构:

/MyApp
   celery_tasks.py
   celeryconfig.py
   __init__.py
我一直在学习一些教程,发现这个和这个,这个对获得芹菜的整体视图非常有帮助

我的脚本是:

芹菜任务.py

from celery import Celery
from celery.task import task

app = Celery()                          # Initialise the app
app.config_from_object('celeryconfig')  # Tell Celery instance to use celeryconfig module


suf = lambda n: "%d%s" % (n, {1: "st", 2: "nd", 3: "rd"}.get(n if n < 20 else n % 10, "th"))
@task
def fav_doctor():
    """Reads doctor.txt file and prints out fav doctor, then adds a new
    number to the file"""

    with open('doctor.txt', 'r+') as f:
        for line in f:
            nums = line.rstrip().split()

            print ('The {} doctor is my favorite'.format(suf(int(nums[0]))))

            for num in nums[1:]:
                print ('Wait! The {} doctor is my favorite'.format(suf(int(num))))

            last_num = int(nums[-1])
            new_last_num = last_num + 1

            f.write(str(new_last_num) + ' ')


@task
def reverse(string):
    return string[::-1]

@task
def add(x, y):
    return x+y
from datetime import timedelta

## List of modules to import when celery starts.
CELERY_IMPORTS = ('celery_tasks',)

## Message Broker (RabbitMQ) settings.
BROKER_URL = 'amqp://'
BROKER_PORT = 5672
#BROKER_TRANSPORT = 'sqlalchemy'
#BROKER_HOST = 'sqlite:///tasks.db'
#BROKER_VHOST = '/'
#BROKER_USER = 'guest'
#BROKER_PASSWORD = 'guest'

## Result store settings.
CELERY_RESULT_BACKEND = 'rpc://'
#CELERY_RESULT_DBURI = 'sqlite:///mydatabase.db'

## Worker settings
#CELERYD_CONCURRENCY = 1
#CELERYD_TASK_TIME_LIMIT = 20
#CELERYD_LOG_FILE = 'celeryd.log'
#CELERYD_LOG_LEVEL = 'INFO'

## Misc
CELERY_IGNORE_RESULT = False
CELERY_TASK_SERIALIZER = 'json'
CELERY_RESULT_SERIALIZER = 'json'
CELERY_ACCEPT_CONTENT=['json']
CELERY_TIMEZONE = 'Europe/Berlin'
CELERY_ENABLE_UTC = True

CELERYBEAT_SCHEDULE = {
    'doctor-every-10-seconds': {
        'task': 'celery_tasks.fav_doctor',
        'schedule': timedelta(seconds=3),
    },
}
from .celery_tasks import app as celery_app # Ensures app is always imported when Django starts so that shared_task will use this app.

__all__ = ['celery_app']
INSTALLED_APPS = [
    ...
     'djcelery',
]
from MyApp.celery_tasks import fav_doctor, reverse, send_email, add

@login_required
def admin_script_dashboard(request):
    if request.method == 'POST':
        form = Admin_Script(request.POST)
        if form.is_valid():
            backup_script_select = form.cleaned_data['backup_script_select']
            dummy_script_select = form.cleaned_data['dummy_script_select']
            print ("backup_script_select: {0}".format(backup_script_select))
            print ("dummy_script_select: {0}".format(dummy_script_select))
            if backup_script_select:
                print ("Backup script exectuting. Please wait...")
                dbackup_script_dir =  str(Path.home()) + '/Software/MyOtherApp/cli-tools/dbbackup_DRAFT.py'
                subprocess.call(" python {} ".format(dbackup_script_dir), shell=True)
                async_result = reverse.delay('Using Celery')
                print ("async_result: {0}".format(async_result))
                result = reverse.AsyncResult(async_result.id)
                print ("result: {0}".format(result))
                print ("Something occured...")
            if dummy_script_select:
                print ("Dummy script exectuting. Please wait...")
                dummy_script_dir =  str(Path.home()) + '/Software/MyOtherApp/cli-tools/dummy.py'
                subprocess.call(" python {} ".format(dummy_script_dir), shell=True)
                async_result = add.delay(2, 5)
                print ("async_result: {0}".format(async_result))
                result = add.AsyncResult(async_result.id)
                print ("result: {0}".format(result))
                print ("Something occured...")
            return render(request, 'MyApp/admin_scripts_db.html')
\uuuu init\uuuuu.py

from celery import Celery
from celery.task import task

app = Celery()                          # Initialise the app
app.config_from_object('celeryconfig')  # Tell Celery instance to use celeryconfig module


suf = lambda n: "%d%s" % (n, {1: "st", 2: "nd", 3: "rd"}.get(n if n < 20 else n % 10, "th"))
@task
def fav_doctor():
    """Reads doctor.txt file and prints out fav doctor, then adds a new
    number to the file"""

    with open('doctor.txt', 'r+') as f:
        for line in f:
            nums = line.rstrip().split()

            print ('The {} doctor is my favorite'.format(suf(int(nums[0]))))

            for num in nums[1:]:
                print ('Wait! The {} doctor is my favorite'.format(suf(int(num))))

            last_num = int(nums[-1])
            new_last_num = last_num + 1

            f.write(str(new_last_num) + ' ')


@task
def reverse(string):
    return string[::-1]

@task
def add(x, y):
    return x+y
from datetime import timedelta

## List of modules to import when celery starts.
CELERY_IMPORTS = ('celery_tasks',)

## Message Broker (RabbitMQ) settings.
BROKER_URL = 'amqp://'
BROKER_PORT = 5672
#BROKER_TRANSPORT = 'sqlalchemy'
#BROKER_HOST = 'sqlite:///tasks.db'
#BROKER_VHOST = '/'
#BROKER_USER = 'guest'
#BROKER_PASSWORD = 'guest'

## Result store settings.
CELERY_RESULT_BACKEND = 'rpc://'
#CELERY_RESULT_DBURI = 'sqlite:///mydatabase.db'

## Worker settings
#CELERYD_CONCURRENCY = 1
#CELERYD_TASK_TIME_LIMIT = 20
#CELERYD_LOG_FILE = 'celeryd.log'
#CELERYD_LOG_LEVEL = 'INFO'

## Misc
CELERY_IGNORE_RESULT = False
CELERY_TASK_SERIALIZER = 'json'
CELERY_RESULT_SERIALIZER = 'json'
CELERY_ACCEPT_CONTENT=['json']
CELERY_TIMEZONE = 'Europe/Berlin'
CELERY_ENABLE_UTC = True

CELERYBEAT_SCHEDULE = {
    'doctor-every-10-seconds': {
        'task': 'celery_tasks.fav_doctor',
        'schedule': timedelta(seconds=3),
    },
}
from .celery_tasks import app as celery_app # Ensures app is always imported when Django starts so that shared_task will use this app.

__all__ = ['celery_app']
INSTALLED_APPS = [
    ...
     'djcelery',
]
from MyApp.celery_tasks import fav_doctor, reverse, send_email, add

@login_required
def admin_script_dashboard(request):
    if request.method == 'POST':
        form = Admin_Script(request.POST)
        if form.is_valid():
            backup_script_select = form.cleaned_data['backup_script_select']
            dummy_script_select = form.cleaned_data['dummy_script_select']
            print ("backup_script_select: {0}".format(backup_script_select))
            print ("dummy_script_select: {0}".format(dummy_script_select))
            if backup_script_select:
                print ("Backup script exectuting. Please wait...")
                dbackup_script_dir =  str(Path.home()) + '/Software/MyOtherApp/cli-tools/dbbackup_DRAFT.py'
                subprocess.call(" python {} ".format(dbackup_script_dir), shell=True)
                async_result = reverse.delay('Using Celery')
                print ("async_result: {0}".format(async_result))
                result = reverse.AsyncResult(async_result.id)
                print ("result: {0}".format(result))
                print ("Something occured...")
            if dummy_script_select:
                print ("Dummy script exectuting. Please wait...")
                dummy_script_dir =  str(Path.home()) + '/Software/MyOtherApp/cli-tools/dummy.py'
                subprocess.call(" python {} ".format(dummy_script_dir), shell=True)
                async_result = add.delay(2, 5)
                print ("async_result: {0}".format(async_result))
                result = add.AsyncResult(async_result.id)
                print ("result: {0}".format(result))
                print ("Something occured...")
            return render(request, 'MyApp/admin_scripts_db.html')
设置中.py

from celery import Celery
from celery.task import task

app = Celery()                          # Initialise the app
app.config_from_object('celeryconfig')  # Tell Celery instance to use celeryconfig module


suf = lambda n: "%d%s" % (n, {1: "st", 2: "nd", 3: "rd"}.get(n if n < 20 else n % 10, "th"))
@task
def fav_doctor():
    """Reads doctor.txt file and prints out fav doctor, then adds a new
    number to the file"""

    with open('doctor.txt', 'r+') as f:
        for line in f:
            nums = line.rstrip().split()

            print ('The {} doctor is my favorite'.format(suf(int(nums[0]))))

            for num in nums[1:]:
                print ('Wait! The {} doctor is my favorite'.format(suf(int(num))))

            last_num = int(nums[-1])
            new_last_num = last_num + 1

            f.write(str(new_last_num) + ' ')


@task
def reverse(string):
    return string[::-1]

@task
def add(x, y):
    return x+y
from datetime import timedelta

## List of modules to import when celery starts.
CELERY_IMPORTS = ('celery_tasks',)

## Message Broker (RabbitMQ) settings.
BROKER_URL = 'amqp://'
BROKER_PORT = 5672
#BROKER_TRANSPORT = 'sqlalchemy'
#BROKER_HOST = 'sqlite:///tasks.db'
#BROKER_VHOST = '/'
#BROKER_USER = 'guest'
#BROKER_PASSWORD = 'guest'

## Result store settings.
CELERY_RESULT_BACKEND = 'rpc://'
#CELERY_RESULT_DBURI = 'sqlite:///mydatabase.db'

## Worker settings
#CELERYD_CONCURRENCY = 1
#CELERYD_TASK_TIME_LIMIT = 20
#CELERYD_LOG_FILE = 'celeryd.log'
#CELERYD_LOG_LEVEL = 'INFO'

## Misc
CELERY_IGNORE_RESULT = False
CELERY_TASK_SERIALIZER = 'json'
CELERY_RESULT_SERIALIZER = 'json'
CELERY_ACCEPT_CONTENT=['json']
CELERY_TIMEZONE = 'Europe/Berlin'
CELERY_ENABLE_UTC = True

CELERYBEAT_SCHEDULE = {
    'doctor-every-10-seconds': {
        'task': 'celery_tasks.fav_doctor',
        'schedule': timedelta(seconds=3),
    },
}
from .celery_tasks import app as celery_app # Ensures app is always imported when Django starts so that shared_task will use this app.

__all__ = ['celery_app']
INSTALLED_APPS = [
    ...
     'djcelery',
]
from MyApp.celery_tasks import fav_doctor, reverse, send_email, add

@login_required
def admin_script_dashboard(request):
    if request.method == 'POST':
        form = Admin_Script(request.POST)
        if form.is_valid():
            backup_script_select = form.cleaned_data['backup_script_select']
            dummy_script_select = form.cleaned_data['dummy_script_select']
            print ("backup_script_select: {0}".format(backup_script_select))
            print ("dummy_script_select: {0}".format(dummy_script_select))
            if backup_script_select:
                print ("Backup script exectuting. Please wait...")
                dbackup_script_dir =  str(Path.home()) + '/Software/MyOtherApp/cli-tools/dbbackup_DRAFT.py'
                subprocess.call(" python {} ".format(dbackup_script_dir), shell=True)
                async_result = reverse.delay('Using Celery')
                print ("async_result: {0}".format(async_result))
                result = reverse.AsyncResult(async_result.id)
                print ("result: {0}".format(result))
                print ("Something occured...")
            if dummy_script_select:
                print ("Dummy script exectuting. Please wait...")
                dummy_script_dir =  str(Path.home()) + '/Software/MyOtherApp/cli-tools/dummy.py'
                subprocess.call(" python {} ".format(dummy_script_dir), shell=True)
                async_result = add.delay(2, 5)
                print ("async_result: {0}".format(async_result))
                result = add.AsyncResult(async_result.id)
                print ("result: {0}".format(result))
                print ("Something occured...")
            return render(request, 'MyApp/admin_scripts_db.html')
在我的视图文件夹中,我有一个特定的视图模块,admin\u scripts.py

from celery import Celery
from celery.task import task

app = Celery()                          # Initialise the app
app.config_from_object('celeryconfig')  # Tell Celery instance to use celeryconfig module


suf = lambda n: "%d%s" % (n, {1: "st", 2: "nd", 3: "rd"}.get(n if n < 20 else n % 10, "th"))
@task
def fav_doctor():
    """Reads doctor.txt file and prints out fav doctor, then adds a new
    number to the file"""

    with open('doctor.txt', 'r+') as f:
        for line in f:
            nums = line.rstrip().split()

            print ('The {} doctor is my favorite'.format(suf(int(nums[0]))))

            for num in nums[1:]:
                print ('Wait! The {} doctor is my favorite'.format(suf(int(num))))

            last_num = int(nums[-1])
            new_last_num = last_num + 1

            f.write(str(new_last_num) + ' ')


@task
def reverse(string):
    return string[::-1]

@task
def add(x, y):
    return x+y
from datetime import timedelta

## List of modules to import when celery starts.
CELERY_IMPORTS = ('celery_tasks',)

## Message Broker (RabbitMQ) settings.
BROKER_URL = 'amqp://'
BROKER_PORT = 5672
#BROKER_TRANSPORT = 'sqlalchemy'
#BROKER_HOST = 'sqlite:///tasks.db'
#BROKER_VHOST = '/'
#BROKER_USER = 'guest'
#BROKER_PASSWORD = 'guest'

## Result store settings.
CELERY_RESULT_BACKEND = 'rpc://'
#CELERY_RESULT_DBURI = 'sqlite:///mydatabase.db'

## Worker settings
#CELERYD_CONCURRENCY = 1
#CELERYD_TASK_TIME_LIMIT = 20
#CELERYD_LOG_FILE = 'celeryd.log'
#CELERYD_LOG_LEVEL = 'INFO'

## Misc
CELERY_IGNORE_RESULT = False
CELERY_TASK_SERIALIZER = 'json'
CELERY_RESULT_SERIALIZER = 'json'
CELERY_ACCEPT_CONTENT=['json']
CELERY_TIMEZONE = 'Europe/Berlin'
CELERY_ENABLE_UTC = True

CELERYBEAT_SCHEDULE = {
    'doctor-every-10-seconds': {
        'task': 'celery_tasks.fav_doctor',
        'schedule': timedelta(seconds=3),
    },
}
from .celery_tasks import app as celery_app # Ensures app is always imported when Django starts so that shared_task will use this app.

__all__ = ['celery_app']
INSTALLED_APPS = [
    ...
     'djcelery',
]
from MyApp.celery_tasks import fav_doctor, reverse, send_email, add

@login_required
def admin_script_dashboard(request):
    if request.method == 'POST':
        form = Admin_Script(request.POST)
        if form.is_valid():
            backup_script_select = form.cleaned_data['backup_script_select']
            dummy_script_select = form.cleaned_data['dummy_script_select']
            print ("backup_script_select: {0}".format(backup_script_select))
            print ("dummy_script_select: {0}".format(dummy_script_select))
            if backup_script_select:
                print ("Backup script exectuting. Please wait...")
                dbackup_script_dir =  str(Path.home()) + '/Software/MyOtherApp/cli-tools/dbbackup_DRAFT.py'
                subprocess.call(" python {} ".format(dbackup_script_dir), shell=True)
                async_result = reverse.delay('Using Celery')
                print ("async_result: {0}".format(async_result))
                result = reverse.AsyncResult(async_result.id)
                print ("result: {0}".format(result))
                print ("Something occured...")
            if dummy_script_select:
                print ("Dummy script exectuting. Please wait...")
                dummy_script_dir =  str(Path.home()) + '/Software/MyOtherApp/cli-tools/dummy.py'
                subprocess.call(" python {} ".format(dummy_script_dir), shell=True)
                async_result = add.delay(2, 5)
                print ("async_result: {0}".format(async_result))
                result = add.AsyncResult(async_result.id)
                print ("result: {0}".format(result))
                print ("Something occured...")
            return render(request, 'MyApp/admin_scripts_db.html')
问题出现在myadmin\u scripts.py文件的行中,其中调用了
async\u result=add.delay(2,5)
。在回溯下面:

[12/Jul/2018 09:23:19] ERROR [django.request:135] Internal Server Error: /MyProject/adminscripts/
Traceback (most recent call last):
  File "/Users/MyMBP/anaconda3/lib/python3.6/site-packages/celery/local.py", line 309, in _get_current_object
    return object.__getattribute__(self, '__thing')
AttributeError: 'PromiseProxy' object has no attribute '__thing'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/MyMBP/anaconda3/lib/python3.6/site-packages/kombu/utils/__init__.py", line 323, in __get__
    return obj.__dict__[self.__name__]
KeyError: 'conf'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/MyMBP/anaconda3/lib/python3.6/site-packages/celery/loaders/base.py", line 158, in _smart_import
    return imp(path)
  File "/Users/MyMBP/anaconda3/lib/python3.6/site-packages/celery/loaders/base.py", line 112, in import_from_cwd
    package=package,
  File "/Users/MyMBP/anaconda3/lib/python3.6/site-packages/celery/utils/imports.py", line 101, in import_from_cwd
    return imp(module, package=package)
  File "/Users/MyMBP/anaconda3/lib/python3.6/site-packages/celery/loaders/base.py", line 106, in import_module
    return importlib.import_module(module, package=package)
  File "/Users/MyMBP/anaconda3/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 978, in _gcd_import
  File "<frozen importlib._bootstrap>", line 961, in _find_and_load
  File "<frozen importlib._bootstrap>", line 948, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'celeryconfig'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/MyMBP/anaconda3/lib/python3.6/site-packages/django/core/handlers/exception.py", line 41, in inner
    response = get_response(request)
  File "/Users/MyMBP/anaconda3/lib/python3.6/site-packages/django/core/handlers/base.py", line 187, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/Users/MyMBP/anaconda3/lib/python3.6/site-packages/django/core/handlers/base.py", line 185, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/Users/MyMBP/anaconda3/lib/python3.6/site-packages/django/contrib/auth/decorators.py", line 23, in _wrapped_view
    return view_func(request, *args, **kwargs)
  File "/Users/MyMBP/Software/MyProject/MyProjectsite/MyProject/views/admin_scripts.py", line 44, in admin_script_dashboard
    async_result = add.delay(2, 5)
  File "/Users/MyMBP/anaconda3/lib/python3.6/site-packages/celery/local.py", line 143, in __getattr__
    return getattr(self._get_current_object(), name)
  File "/Users/MyMBP/anaconda3/lib/python3.6/site-packages/celery/local.py", line 311, in _get_current_object
    return self.__evaluate__()
  File "/Users/MyMBP/anaconda3/lib/python3.6/site-packages/celery/local.py", line 341, in __evaluate__
    thing = Proxy._get_current_object(self)
  File "/Users/MyMBP/anaconda3/lib/python3.6/site-packages/celery/local.py", line 101, in _get_current_object
    return loc(*self.__args, **self.__kwargs)
  File "/Users/MyMBP/anaconda3/lib/python3.6/site-packages/celery/app/base.py", line 270, in _task_from_fun
    '__wrapped__': fun}, **options))()
  File "/Users/MyMBP/anaconda3/lib/python3.6/site-packages/celery/app/task.py", line 201, in __new__
    instance.bind(app)
  File "/Users/MyMBP/anaconda3/lib/python3.6/site-packages/celery/app/task.py", line 365, in bind
    conf = app.conf
  File "/Users/MyMBP/anaconda3/lib/python3.6/site-packages/kombu/utils/__init__.py", line 325, in __get__
    value = obj.__dict__[self.__name__] = self.__get(obj)
  File "/Users/MyMBP/anaconda3/lib/python3.6/site-packages/celery/app/base.py", line 638, in conf
    return self._get_config()
  File "/Users/MyMBP/anaconda3/lib/python3.6/site-packages/celery/app/base.py", line 454, in _get_config
    self.loader.config_from_object(self._config_source)
  File "/Users/MyMBP/anaconda3/lib/python3.6/site-packages/celery/loaders/base.py", line 140, in config_from_object
    obj = self._smart_import(obj, imp=self.import_from_cwd)
  File "/Users/MyMBP/anaconda3/lib/python3.6/site-packages/celery/loaders/base.py", line 161, in _smart_import
    return symbol_by_name(path, imp=imp)
  File "/Users/MyMBP/anaconda3/lib/python3.6/site-packages/kombu/utils/__init__.py", line 96, in symbol_by_name
    module = imp(module_name, package=package, **kwargs)
  File "/Users/MyMBP/anaconda3/lib/python3.6/site-packages/celery/loaders/base.py", line 112, in import_from_cwd
    package=package,
  File "/Users/MyMBP/anaconda3/lib/python3.6/site-packages/celery/utils/imports.py", line 101, in import_from_cwd
    return imp(module, package=package)
  File "/Users/MyMBP/anaconda3/lib/python3.6/site-packages/celery/loaders/base.py", line 106, in import_module
    return importlib.import_module(module, package=package)
  File "/Users/MyMBP/anaconda3/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 978, in _gcd_import
  File "<frozen importlib._bootstrap>", line 961, in _find_and_load
  File "<frozen importlib._bootstrap>", line 948, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'celeryconfig'
[12/Jul/2018 09:23:19]错误[django.request:135]内部服务器错误:/MyProject/adminscript/
回溯(最近一次呼叫最后一次):
文件“/Users/MyMBP/anaconda3/lib/python3.6/site packages/cellery/local.py”,第309行,位于当前对象中
返回对象.\uuuu getattribute\uuuuu(self,\uuuu thing'))
AttributeError:“PromiseProxy”对象没有属性“\u thing”
在处理上述异常期间,发生了另一个异常:
回溯(最近一次呼叫最后一次):
文件“/Users/MyMBP/anaconda3/lib/python3.6/site-packages/kombu/utils/_-init__.py”,第323行,在__
返回对象名称
KeyError:'conf'
在处理上述异常期间,发生了另一个异常:
回溯(最近一次呼叫最后一次):
文件“/Users/MyMBP/anaconda3/lib/python3.6/site packages/芹菜/loaders/base.py”,第158行,在智能导入中
返回imp(路径)
文件“/Users/MyMBP/anaconda3/lib/python3.6/site packages/芹菜/loaders/base.py”,第112行,从cwd导入
包装=包装,
文件“/Users/MyMBP/anaconda3/lib/python3.6/site packages/芹菜/utils/imports.py”,第101行,从cwd导入
返回imp(模块,包=包)
文件“/Users/MyMBP/anaconda3/lib/python3.6/site packages/芹菜/loaders/base.py”,第106行,在导入模块中
返回importlib.import\u模块(模块,包=包)
文件“/Users/MyMBP/anaconda3/lib/python3.6/importlib/_init__.py”,第126行,在导入模块中
return _bootstrap._gcd_import(名称[级别:],包,级别)
文件“”,第978行,在_gcd_import中
文件“”,第961行,在“查找”和“加载”中
文件“”,第948行,在“查找”和“加载”中解锁
ModuleNotFoundError:没有名为“celeryconfig”的模块
在处理上述异常期间,发生了另一个异常:
回溯(最近一次呼叫最后一次):
文件“/Users/MyMBP/anaconda3/lib/python3.6/site packages/django/core/handlers/exception.py”,第41行,在内部
响应=获取响应(请求)
文件“/Users/MyMBP/anaconda3/lib/python3.6/site packages/django/core/handlers/base.py”,第187行,在“获取”响应中
response=self.process\u异常\u由\u中间件(e,请求)
文件“/Users/MyMBP/anaconda3/lib/python3.6/site packages/django/core/handlers/base.py”,第185行,在“获取”响应中
响应=包装的回调(请求,*回调参数,**回调参数)
文件“/Users/MyMBP/anaconda3/lib/python3.6/site packages/django/contrib/auth/decorators.py”,第23行,在包装视图中
返回视图功能(请求,*args,**kwargs)
文件“/Users/MyMBP/Software/MyProject/MyProjectsite/MyProject/views/admin\u scripts.py”,第44行,在admin\u script\u仪表板中
async_result=add.delay(2,5)
文件“/Users/MyMBP/anaconda3/lib/python3.6/site packages/芹菜/local.py”,第143行,在__
返回getattr(self.\u get\u current\u object(),name)
文件“/Users/MyMBP/anaconda3/lib/python3.6/site packages/cellery/local.py”,第311行,位于当前对象中
返回自我。评估
文件“/Users/MyMBP/anaconda3/lib/python3.6/site packages/芹菜/local.py”,第341行,在__
thing=Proxy.\u获取\u当前\u对象(self)
文件“/Users/MyMBP/anaconda3/lib/python3.6/site packages/cellery/local.py”,第101行,在“获取当前”对象中
返回loc(*self.\u args,**self.\u kwargs)
文件“/Users/MyMBP/anaconda3/lib/python3.6/site packages/cellery/app/base.py”,第270行,在“任务”中
“uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu
文件“/Users/MyMBP/anaconda3/lib/python3.6/site packages/cellery/app/task.py”,第201行,新__
instance.bind(应用程序)
文件“/Users/MyMBP/anaconda3/lib/python3.6/site packages/芹菜/app/task.py”,第365行,在绑定中
conf=app.conf
文件“/Users/MyMBP/anaconda3/lib/python3.6/site-packages/kombu/utils/_-init__.py”,第325行,在__
value=obj.\uuuu dict\uuuu[self.\uuuuuu name\uuuuu]=self.\uuuuu get(obj)
文件“/Users/MyMBP/anaconda3/lib/python3.6/site packages/芹菜/app/base.py”,第638行,在conf中
返回self.\u获取\u配置()
文件“/Users/MyMBP/anaconda3/lib/python3.6/site-packages/芹菜/app/base.py”,第454行,在“获取”配置中
self.loader.config\u来自\u对象(self.\u config\u源)
文件“/Users/MyMBP/anaconda3/lib/python3.6/site packages/芹菜/loaders/base.py”,第140行,在config_from_对象中
obj=self.\u智能\u导入(obj,imp=self.import\u from\u cwd)
文件“/Users/MyMBP/anaconda3/lib/python3.6/site packages/芹菜/loaders/base.py”,第161行,在智能导入中
按名称返回符号(路径,imp=imp)
文件“/Users/MyMBP/anaconda3/lib/python3.6/site packages/kombu/utils/__init__.py”,第96行,以symbol_by_名称显示
模块=imp(模块名称,包=包,**kwargs)
文件“/Users/MyMBP/anaconda3/lib/python3.6/site packages/芹菜/loaders/base.py”,第112行,从cwd导入
包装=包装,
文件“/Users/MyMBP/anaconda3/lib/python3.6/site packages/芹菜/utils/imports.py”,第101行,从cwd导入
返回imp(模块,包=包)
文件“/Users/MyMBP/anaconda3/lib/python3.6/site packages/芹菜/loaders/base.py”,第106行,在导入模块中
返回importlib.import\u模块(模块,包