В настоящее время пытаюсь инициировать работника для моего приложения django, к сожалению, я получаю эту ошибку:
PS C:\Users\User\Documents\Codes\highlightreel> celery -A highlightreel worker -l info
Traceback (most recent call last):
File "c:\program files\python38\lib\runpy.py", line 192, in _run_module_as_main
return _run_code(code, main_globals, None,
File "c:\program files\python38\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Program Files\Python38\Scripts\celery.exe\__main__.py", line 7, in <module>
File "c:\program files\python38\lib\site-packages\celery\__main__.py", line 16, in main
_main()
File "c:\program files\python38\lib\site-packages\celery\bin\celery.py", line 322, in main
cmd.execute_from_commandline(argv)
File "c:\program files\python38\lib\site-packages\celery\bin\celery.py", line 495, in execute_from_commandline
super(CeleryCommand, self).execute_from_commandline(argv)))
File "c:\program files\python38\lib\site-packages\celery\bin\base.py", line 305, in execute_from_commandline
return self.handle_argv(self.prog_name, argv[1:])
File "c:\program files\python38\lib\site-packages\celery\bin\celery.py", line 487, in handle_argv
return self.execute(command, argv)
File "c:\program files\python38\lib\site-packages\celery\bin\celery.py", line 415, in execute
return cls(
File "c:\program files\python38\lib\site-packages\celery\bin\worker.py", line 223, in run_from_argv
return self(*args, **options)
File "c:\program files\python38\lib\site-packages\celery\bin\base.py", line 253, in __call__
ret = self.run(*args, **kwargs)
File "c:\program files\python38\lib\site-packages\celery\bin\worker.py", line 253, in run
worker = self.app.Worker(
File "c:\program files\python38\lib\site-packages\celery\worker\worker.py", line 97, in __init__
self.on_before_init(**kwargs)
File "c:\program files\python38\lib\site-packages\celery\apps\worker.py", line 93, in on_before_init
trace.setup_worker_optimizations(self.app, self.hostname)
File "c:\program files\python38\lib\site-packages\celery\app\trace.py", line 596, in setup_worker_optimizations
app.finalize()
File "c:\program files\python38\lib\site-packages\celery\app\base.py", line 538, in finalize
_announce_app_finalized(self)
File "c:\program files\python38\lib\site-packages\celery\_state.py", line 54, in _announce_app_finalized
callback(app)
File "c:\program files\python38\lib\site-packages\celery\app\__init__.py", line 59, in <lambda>
lambda app: app._task_from_fun(fun, **options)
File "c:\program files\python38\lib\site-packages\celery\app\base.py", line 452, in _task_from_fun
'__header__': staticmethod(head_from_fun(fun, bound=bind)),
File "c:\program files\python38\lib\site-packages\celery\utils\functional.py", line 279, in head_from_fun
namespace = {'__name__': fun.__module__}
AttributeError: 'method-wrapper' object has no attribute '__module__'
Я запускаю это с powereditor в папке проекта. Функция запускается, если я не включаю проект в запрос, но это не отображает задачи.
Не уверены, что важно, но, пожалуйста, найдите django код ниже.
Celery.py
from __future__ import absolute_import, unicode_literals
import os
from celery import Celery
# set the default Django settings module for the 'celery' program.
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'highlightreel.settings')
app = Celery('highlightreel')
# Using a string here means the worker doesn't have to serialize
# the configuration object to child processes.
# - namespace='CELERY' means all celery-related configuration keys
# should have a `CELERY_` prefix.
app.config_from_object('django.conf:settings', namespace='CELERY')
# Load task modules from all registered Django app configs.
app.autodiscover_tasks()
@app.task(bind=True)
def debug_task(self):
print('Request: {0!r}'.format(self.request))
Из settings.py
CELERY_BROKER_URL = 'amqp://localhost'
CELERY_ACCEPT_CONTENT = ['json']
CElERY_TASK_SERIALIZER = 'json'
Из splitter.py
from celery import shared_task
@shared_task
class Splitter():
def __init__(**kwargs):
#Variables