python - django- celery : TypeError: can only concatenate tuple (not "NoneType") to tuple

标签 python django celery django-celery

我最近开始将 rabbitmq 和 celery 与 django 一起使用。我正在使用 django-celery、django-celery-email 和邮局以异步方式发送电子邮件。 安装所有这些包后,我的 settings.py 看起来像

INSTALLED_APPS = [
#other apps
'djcelery',
'djcelery_email',
'post_office'
]


# setup celery
import djcelery
djcelery.setup_loader()

# using post office as the default email backend 
EMAIL_BACKEND = 'post_office.EmailBackend'
# using djcelery's email backend as a backend for post office 

POST_OFFICE_BACKEND = 'djcelery_email.backends.CeleryEmailBackend'

POST_OFFICE = {
    'DEFAULT_PRIORITY' : 'now'
}

EMAIL_HOST = 'YOUR_HOST_NAME'
EMAIL_HOST_USER = "YOUR_HOST_USER_NAME"
EMAIL_PORT = 25  # default smtp port
EMAIL_HOST_PASSWORD = "YOUR_HOST_USER_PASSWORD"
EMAIL_USE_TLS = False
DEFAULT_FROM_EMAIL = 'testing@example.com'

当我尝试通过命令运行 django-celery 时

**python manage.py celeryd**

正在通过以下错误

Traceback (most recent call last):
  File "manage.py", line 22, in <module>
    execute_from_command_line(sys.argv)
  File "/home/ubuntu/edyodavirtual/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 364, in execute_from_command_line
    utility.execute()
  File "/home/ubuntu/edyodavirtual/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 356, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/ubuntu/edyodavirtual/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 206, in fetch_command
    klass = load_command_class(app_name, subcommand)
  File "/home/ubuntu/edyodavirtual/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 40, in load_command_class
    module = import_module('%s.management.commands.%s' % (app_name, name))
  File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/home/ubuntu/edyodavirtual/local/lib/python2.7/site-packages/djcelery/management/commands/celeryd.py", line 16, in <module>
    class Command(CeleryCommand):
  File "/home/ubuntu/edyodavirtual/local/lib/python2.7/site-packages/djcelery/management/commands/celeryd.py", line 20, in Command
    worker.get_options() +
TypeError: can only concatenate tuple (not "NoneType") to tuple

这里有人帮我解决这个问题

最佳答案

只需在“~/anaconda2/envs/test_django/lib/python3.6/site-packages/djcelery/management/commands/celery.py”中注释掉这些行,如下所示:

 14     #    options = (CeleryCommand.options +
 15     #           base.get_options() +
 16     #           base.preload_options)

然后就可以了。

关于python - django- celery : TypeError: can only concatenate tuple (not "NoneType") to tuple,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49085230/

相关文章:

http - 是否可以将 Celery 与另一种编程语言一起使用?

python - GStreamer 总线发送 None 消息

python - Apache 与 Django/Matplotlib 应用程序一起挂起

python - 在 Django 中使用 HttpRequest.build_absolute_uri(location) 时出现错误

python - django 模型类是单例/仅实现一次吗?

flask - celery + Redis + Flask如何获得待通过 celery 执行的工作量

django - ConnectionAbortedError - 如果 Celery 停止/失败或 Redis 未启动。我如何捕获/除此错误/

python - fileinput.hook_compressed 有时给我字符串,有时给我字节

Python BeautifulSoup - 获取 Div Select Option 中的值

python - 将两个不同大小的 pandas 数据帧按元素相乘,并添加一个维度作为附加索引/列