- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
尝试让它工作:Django 1.6.11 + Celery 3.1.19 + Kombu 3.0.33 在 Ubuntu 14.04 上使用教程 http://docs.celeryproject.org/en/latest/django/first-steps-with-django.html所以我从这里完全重复了项目结构: https://github.com/celery/celery/tree/3.1/examples/django/
当我从 django 项目根目录运行命令时:/var/www/engine$ celery worker -l INFO -B
在我的应用 vk_wall 中,我有包含 add 任务的 tasks.py 文件。
我得到一个错误:
graph@engine:/var/www/engine$ celery worker -l INFO -B
[2016-01-17 18:41:41,159: WARNING/MainProcess] /usr/local/lib/python3.4/dist-packages/celery/apps/worker.py:161: CDeprecationWarning:
Starting from version 3.2 Celery will refuse to accept pickle by default.
The pickle serializer is a security concern as it may give attackers
the ability to execute any command. It's important to secure
your broker from unauthorized access when using pickle, so we think
that enabling pickle should require a deliberate action and not be
the default choice.
If you depend on pickle then you should set a setting to disable this
warning and to be sure that everything will continue working
when you upgrade to Celery 3.2::
CELERY_ACCEPT_CONTENT = ['pickle', 'json', 'msgpack', 'yaml']
You must only enable the serializers that you will actually use.
warnings.warn(CDeprecationWarning(W_PICKLE_DEPRECATED))
-------------- celery@engine v3.1.19 (Cipater)
---- **** -----
--- * *** * -- Linux-3.13.0-24-generic-x86_64-with-Ubuntu-14.04-trusty
-- * - **** ---
- ** ---------- [config]
- ** ---------- .> app: default:0x7f9c6495cc18 (.default.Loader)
- ** ---------- .> transport: amqp://guest:**@localhost:5672//
- ** ---------- .> results: disabled
- *** --- * --- .> concurrency: 2 (prefork)
-- ******* ----
--- ***** ----- [queues]
-------------- .> celery exchange=celery(direct) key=celery
[tasks]
[2016-01-17 18:41:41,187: INFO/Beat] beat: Starting...
[2016-01-17 18:41:41,212: ERROR/Beat] Removing corrupted schedule file 'celerybeat-schedule': error(13, 'Permission denied')
Traceback (most recent call last):
File "/usr/local/lib/python3.4/dist-packages/kombu/utils/__init__.py", line 323, in __get__
return obj.__dict__[self.__name__]
KeyError: 'scheduler'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.4/dist-packages/celery/beat.py", line 376, in setup_schedule
self._store = self._open_schedule()
File "/usr/local/lib/python3.4/dist-packages/celery/beat.py", line 366, in _open_schedule
return self.persistence.open(self.schedule_filename, writeback=True)
File "/usr/lib/python3.4/shelve.py", line 239, in open
return DbfilenameShelf(filename, flag, protocol, writeback)
File "/usr/lib/python3.4/shelve.py", line 223, in __init__
Shelf.__init__(self, dbm.open(filename, flag), protocol, writeback)
File "/usr/lib/python3.4/dbm/__init__.py", line 94, in open
return mod.open(file, flag, mode)
_gdbm.error: [Errno 13] Permission denied
[2016-01-17 18:41:41,219: ERROR/Beat] Process Beat
Traceback (most recent call last):
File "/usr/local/lib/python3.4/dist-packages/kombu/utils/__init__.py", line 323, in __get__
return obj.__dict__[self.__name__]
KeyError: 'scheduler'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.4/dist-packages/celery/beat.py", line 376, in setup_schedule
self._store = self._open_schedule()
File "/usr/local/lib/python3.4/dist-packages/celery/beat.py", line 366, in _open_schedule
return self.persistence.open(self.schedule_filename, writeback=True)
File "/usr/lib/python3.4/shelve.py", line 239, in open
return DbfilenameShelf(filename, flag, protocol, writeback)
File "/usr/lib/python3.4/shelve.py", line 223, in __init__
Shelf.__init__(self, dbm.open(filename, flag), protocol, writeback)
File "/usr/lib/python3.4/dbm/__init__.py", line 94, in open
return mod.open(file, flag, mode)
_gdbm.error: [Errno 13] Permission denied
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.4/dist-packages/billiard/process.py", line 292, in _bootstrap
self.run()
File "/usr/local/lib/python3.4/dist-packages/celery/beat.py", line 545, in run
self.service.start(embedded_process=True)
File "/usr/local/lib/python3.4/dist-packages/celery/beat.py", line 464, in start
humanize_seconds(self.scheduler.max_interval))
File "/usr/local/lib/python3.4/dist-packages/kombu/utils/__init__.py", line 325, in __get__
value = obj.__dict__[self.__name__] = self.__get(obj)
File "/usr/local/lib/python3.4/dist-packages/celery/beat.py", line 504, in scheduler
return self.get_scheduler()
File "/usr/local/lib/python3.4/dist-packages/celery/beat.py", line 499, in get_scheduler
lazy=lazy)
File "/usr/local/lib/python3.4/dist-packages/celery/utils/imports.py", line 53, in instantiate
return symbol_by_name(name)(*args, **kwargs)
File "/usr/local/lib/python3.4/dist-packages/celery/beat.py", line 358, in __init__
Scheduler.__init__(self, *args, **kwargs)
File "/usr/local/lib/python3.4/dist-packages/celery/beat.py", line 185, in __init__
self.setup_schedule()
File "/usr/local/lib/python3.4/dist-packages/celery/beat.py", line 378, in setup_schedule
self._store = self._destroy_open_corrupted_schedule(exc)
File "/usr/local/lib/python3.4/dist-packages/celery/beat.py", line 372, in _destroy_open_corrupted_schedule
return self._open_schedule()
File "/usr/local/lib/python3.4/dist-packages/celery/beat.py", line 366, in _open_schedule
return self.persistence.open(self.schedule_filename, writeback=True)
File "/usr/lib/python3.4/shelve.py", line 239, in open
return DbfilenameShelf(filename, flag, protocol, writeback)
File "/usr/lib/python3.4/shelve.py", line 223, in __init__
Shelf.__init__(self, dbm.open(filename, flag), protocol, writeback)
File "/usr/lib/python3.4/dbm/__init__.py", line 94, in open
return mod.open(file, flag, mode)
_gdbm.error: [Errno 13] Permission denied[2016-01-17 18:41:41,227: INFO/MainProcess] Connected to amqp://guest:**@127.0.0.1:5672//
[2016-01-17 18:41:41,252: INFO/MainProcess] mingle: searching for neighbors
[2016-01-17 18:41:42,272: INFO/MainProcess] mingle: all alone
[2016-01-17 18:41:42,302: WARNING/MainProcess] celery@engine ready.
[2016-01-17 18:42:45,778: ERROR/MainProcess] Received unregistered task of type 'vk_wall.tasks.mul'.
The message has been ignored and discarded.
Did you remember to import the module containing this task?
Or maybe you are using relative imports?
Please see http://bit.ly/gLye1c for more information.
The full contents of the message body was:
{'expires': None, 'errbacks': None, 'callbacks': None, 'args': (2, 5), 'kwargs': {}, 'utc': True, 'retries': 0, 'eta': '2016-01-17T15:42:55.746877+00:00', 'task': 'vk_wall.tasks.mul', 'id': '38c3c3d3-3b53-4c58-a308-d41ed24ea613', 'timelimit': (None, None), 'chord': None, 'taskset': None} (302b)
Traceback (most recent call last):
File "/usr/local/lib/python3.4/dist-packages/celery/worker/consumer.py", line 455, in on_task_received
strategies[name](message, body,
KeyError: 'vk_wall.tasks.mul'
[2016-01-17 18:42:45,786: ERROR/MainProcess] Received unregistered task of type 'vk_wall.tasks.add'.
The message has been ignored and discarded.
Did you remember to import the module containing this task?
Or maybe you are using relative imports?
Please see http://bit.ly/gLye1c for more information.
The full contents of the message body was:
{'expires': None, 'errbacks': None, 'callbacks': None, 'args': (2, 2), 'kwargs': {}, 'utc': True, 'retries': 0, 'eta': None, 'task': 'vk_wall.tasks.add', 'id': 'cc04ddae-024e-4884-9a10-7a7066206fa9', 'timelimit': (None, None), 'chord': None, 'taskset': None} (264b)
Traceback (most recent call last):
File "/usr/local/lib/python3.4/dist-packages/celery/worker/consumer.py", line 455, in on_task_received
strategies[name](message, body,
KeyError: 'vk_wall.tasks.add'
我看到 celery beat 问题,同样在回溯中,我看到 celery 可以找到 add、mul、get_wallposts_by_owner_id 任务,但无法执行它们(在我的 views.py 中,我对它们进行了校准:from vk_wall.tasks import add, mul res_mul = mul.apply_async((2, 5), queue='celery', countdown=10) res_add = add.delay(2, 2))
我还安装了 django-celery 以在管理面板中查看任务。
顺便说一句:在初学者教程中我能够让 celery 工作并执行任务 http://docs.celeryproject.org/en/latest/getting-started/next-steps.html但现在需要 django 来访问任务中的模型。
更新:我的 settings.py django 文件
BROKER_URL = 'django://'
#: Only add pickle to this list if your broker is secured
#: from unwanted access (see userguide/security.html)
CELERY_ACCEPT_CONTENT = ['json']
CELERY_TASK_RESULT_EXPIRES=3600,
#CELERY_RESULT_BACKEND='amqp',
CELERY_RESULT_BACKEND='djcelery.backends.database:DatabaseBackend',
#CELERY_RESULT_BACKEND='djcelery.backends.cache:CacheBackend',
CELERY_RESULT_SERIALIZER = 'pickle', #json
CELERY_TASK_SERIALIZER = 'pickle',
CELERY_IMPORTS=["vk_wall.tasks"]
UPD2:我的celery.py文件(位于firstapp/firstapp,与django的settings.py同级)
from __future__ import absolute_import
import os
from celery import Celery
# set the default Django settings module for the 'celery' program.
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'firstapp.settings')
from django.conf import settings # noqa
app = Celery('firstapp')
# Using a string here means the worker will not have to
# pickle the object when using Windows.
app.config_from_object('django.conf:settings')
app.autodiscover_tasks(lambda: settings.INSTALLED_APPS)
@app.task(bind=True)
def debug_task(self):
print('Request: {0!r}'.format(self.request))
UPD3:完整追溯
graph@engine:/var/www/engine$ celery worker -A firstapp.settings -l debug
Traceback (most recent call last):
File "/usr/local/bin/celery", line 11, in <module>
sys.exit(main())
File "/usr
/local/lib/python3.4/dist-packages/celery/__main__.py", line 30, in main
main()
File "/usr/local/lib/python3.4/dist-packages/celery/bin/celery.py", line 81, in main
cmd.execute_from_commandline(argv)
File "/usr/local/lib/python3.4/dist-packages/celery/bin/celery.py", line 770, in execute_from_commandline
super(CeleryCommand, self).execute_from_commandline(argv)))
File "/usr/local/lib/python3.4/dist-packages/celery/bin/base.py", line 309, in execute_from_commandline
argv = self.setup_app_from_commandline(argv)
File "/usr/local/lib/python3.4/dist-packages/celery/bin/base.py", line 469, in setup_app_from_commandline
self.app = self.find_app(app)
File "/usr/local/lib/python3.4/dist-packages/celery/bin/base.py", line 489, in find_app
return find_app(app, symbol_by_name=self.symbol_by_name)
File "/usr/local/lib/python3.4/dist-packages/celery/app/utils.py", line 229, in find_app
sym = symbol_by_name(app, imp=imp)
File "/usr/local/lib/python3.4/dist-packages/celery/bin/base.py", line 492, in symbol_by_name
return symbol_by_name(name, imp=imp)
File "/usr/local/lib/python3.4/dist-packages/kombu/utils/__init__.py", line 96, in symbol_by_name
module = imp(module_name, package=package, **kwargs)
File "/usr/local/lib/python3.4/dist-packages/celery/utils/imports.py", line 101, in import_from_cwd
return imp(module, package=package)
File "/usr/lib/python3.4/importlib/__init__.py", line 109, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 2254, in _gcd_import
File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
File "<frozen importlib._bootstrap>", line 2224, in _find_and_load_unlocked
ImportError: No module named 'firstapp'
最佳答案
在命令行中使用明确的设置路径调用您的 celery worker:
celery worker -A firstapp.celery
看来根本原因是:
vk_wall.tasks.add
发生这种情况是因为您没有指定 celery 的设置源。它应该加载 Django 项目的设置或单独的设置文件。
关于python - 无法使用教程开始工作 Django Celery Kombu,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34840462/
我正在做一个关于代码学院的教程,我在这里收到一个错误,说“看起来你的函数没有返回‘唉,你没有资格获得信用卡。资本主义就是这样残酷。’”当收入参数为 75 时。”但是该字符串在控制台中返回(由于某种原因
我正在阅读 Go 的官方教程,但很难理解 Channel 和 Buffered Channels 之间的区别。教程的链接是 https://tour.golang.org/concurrency/2和
就目前而言,这个问题不适合我们的问答形式。我们希望答案得到事实、引用资料或专业知识的支持,但这个问题可能会引发辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit the
关闭。这个问题是off-topic .它目前不接受答案。 想改进这个问题? Update the question所以它是on-topic对于堆栈溢出。 9年前关闭。 Improve this que
已关闭。此问题不符合Stack Overflow guidelines 。目前不接受答案。 要求我们推荐或查找工具、库或最喜欢的场外资源的问题对于 Stack Overflow 来说是偏离主题的,因为
作为 iOS 新手,有大量书籍可以满足学习基础知识的需求。现在,我想转向一些高级阅读,例如 OAuth 和 SQLite 以及动态 API 派生的 TableView 等。您可以推荐任何资源吗? 最佳
就目前而言,这个问题不适合我们的问答形式。我们希望答案得到事实、引用资料或专业知识的支持,但这个问题可能会引发辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit the
关闭。这个问题是opinion-based .它目前不接受答案。 想要改进这个问题? 更新问题,以便 editing this post 可以用事实和引用来回答它. 关闭 8 年前。 Improve
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 我们不允许提问寻求书籍、工具、软件库等的推荐。您可以编辑问题,以便用事实和引用来回答。 关闭 8 年前。
前言 很多同学都知道,我们常见的CTF赛事除了解题赛之外,还有一种赛制叫AWD赛制。在这种赛制下,我们战队会拿到一个或多个服务器。服务器的连接方式通常是SSH链接,并且可能一个战队可能会同时有
Memcached是一个自由开源的,高性能,分布式内存键值对缓存系统 Memcached 是一种基于内存的key-value存储,用来存储小块的任意数据(字符串、对象),这些数据可以是数据库调用、A
Perl 又名实用报表提取语言, 是 Practical Extraction and Report Language 的缩写 Perl 是由 拉里·沃尔(Larry Wall)于19
WSDL 是 Web Services Description Language 的缩写,翻译成中文就是网络服务描述语言 WSDL 是一门基于 XML 的语言,用于描述 Web Services 以
关闭。这个问题不满足Stack Overflow guidelines .它目前不接受答案。 想改善这个问题吗?更新问题,使其成为 on-topic对于堆栈溢出。 6年前关闭。 Improve thi
我正在寻找解释在 WPF 中创建自定义用户控件的教程。 我想要一个控件,它结合了一个文本 block 、一个文本框和一个启动通用文件打开对话框的按钮。我已经完成了布局,一切都连接好了。它有效,但它是三
就目前而言,这个问题不适合我们的问答形式。我们希望答案得到事实、引用资料或专业知识的支持,但这个问题可能会引发辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit the
我接近 fourth page of the Django tutorial 的开始看着vote查看,最后是这样的: # Always return an HttpResponseRedirect a
就目前而言,这个问题不适合我们的问答形式。我们希望答案得到事实、引用资料或专业知识的支持,但这个问题可能会引发辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit the
是否有任何好的 Qt QSS 教程,或者在某个地方我可以看到样式小部件的示例?如果某处可用,我想要一些完整的引用。除了有关如何设置按钮或某些选项卡样式的小教程外,我找不到任何其他内容。 最佳答案 Qt
就目前而言,这个问题不适合我们的问答形式。我们希望答案得到事实、引用或专业知识的支持,但这个问题可能会引起辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit the he
我是一名优秀的程序员,十分优秀!