celery 时区问题工作流的问题

G:\python3_django\DFpro\mypro (win)(py3_django) λ python manage.py celery worker --loglevel=infoTraceback (most recent call last):& File "manage.py", line 10, inexecute_from_command_line(sys.argv)& File "C:\virtualenv\py3_django\lib\site-packages\django\core\management\__init__.py", line 364, in execute_from_command_line& & utility.execute()& File "C:\virtualenv\py3_django\lib\site-packages\django\core\management\__init__.py", line 356, in execute& & self.fetch_command(subcommand).run_from_argv(self.argv)& File "C:\virtualenv\py3_django\lib\site-packages\django\core\management\__init__.py", line 206, in fetch_command& & klass = load_command_class(app_name, subcommand)& File "C:\virtualenv\py3_django\lib\site-packages\django\core\management\__init__.py", line 40, in load_command_class& & module = import_module('%mands.%s' % (app_name, name))& File "C:\virtualenv\py3_django\lib\importlib\__init__.py", line 126, in import_module& & return _bootstrap._gcd_import(name[level:], package, level)& File "", line 978, in _gcd_import& File "", line 961, in _find_and_load& File "", line 950, in _find_and_load_unlocked& File "", line 655, in _load_unlocked& File "", line 678, in exec_module& File "", line 205, in _call_with_frames_removed& File "C:\virtualenv\py3_django\lib\site-packages\djcelery\management\commands\celery.py", line 6, infrom djcelery.management.base import CeleryCommand& File "C:\virtualenv\py3_django\lib\site-packages\djcelery\management\base.py", line 59, inclass CeleryCommand(BaseCommand):
File "C:\virtualenv\py3_django\lib\site-packages\djcelery\management\base.py", line 60, in CeleryCommand
options = BaseCommand.option_list
AttributeError: type object 'BaseCommand' has no attribute 'option_list'
解决办法:pip install django==1.8&
Celery == 3.1 django == 1.10 django-celery == 3.1.17
这个搭配运行有问题
在Django 1.8中被弃用,并在Django 1.10中删除。看起来Django的扩展,但从那以后还没有一个新的版本。
阅读(...) 评论()关于 celery 的 taskid 跟 flower 不匹配问题 - V2EX
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
已注册用户请 &
推荐学习书目
Python Sites
值得关注的项目
Python 编程
关于 celery 的 taskid 跟 flower 不匹配问题
· 111 天前 · 493 次点击
RT,我这里用 celery 做了一个小东西,是根据任务生成的 id,去针对 flower 上的接口进行监控的。
/api/task/result/fe4f4cd8-cba2-4fc4-ed2402579
但问题来了,我后端脚本使用的是类似于下面这样获取的 id:
task_id = task.delay(url,host).id
结果我发现这样生成的 id,竟然有部分在 flower 压根找不到。
我检查了下,本以为是我在 task 里面嵌套了 task 的缘故,但去掉 delay 直接调用那个嵌套 task 的主函数也这样。
按我的理解,task id 不管任务状态为 RECEIVED,还是 STARTED,它的 id 既然用 delay 生成了,应该在 flower 是找的到的,问题现在完全没发现踪迹。
想问问各位大佬,这到底咋回事啊?
第 1 条附言 &·& 110 天前
我这边似乎查出了部分原因,那个会出问题的 task,只要执行的数目(包括 STARTED 和 RECEIVED ),只要数目不超过我这边起的 worker 数就不会出问题,后端 task 生成的 id 就能在 flower 里面找的到。
那么问题来了,有大佬知道什么原因么?
或者,最不济,咱们这里换种笨办法。
有大佬愿意给讲下,如何限制指定任务在单机器或者集群里同时存在的个数么(包括 STARTED 和 RECEIVED )?
我记得好像要把 STARTED 和 RECEIVED 的任务一起限制的话,好像不能限制这种指定的任务个数存在的个数,不知道有没有大佬有办法。
2 回复 &| &直到
16:02:20 +08:00
& &111 天前
enqueue 后立即查看 flower,如果当时有,隔段时间没有,可能是配置里没存储结果,被清理了。
& &111 天前
@ 应该不是这个问题,是获取了 task.delay(url,host).id 后马上去搜索,并没有发现。
然后过了一段时间候,仍然没有。
& · & 2162 人在线 & 最高记录 3541 & · &
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.0 · 50ms · UTC 10:32 · PVG 18:32 · LAX 02:32 · JFK 05:32? Do have faith in what you're doing.python的学习和理解-celery最佳实践_百度文库
两大类热门资源免费畅读
续费一年阅读会员,立省24元!
python的学习和理解-celery最佳实践
阅读已结束,下载文档到电脑
想免费下载本文?
定制HR最喜欢的简历
下载文档到电脑,方便使用
还剩3页未读,继续阅读
定制HR最喜欢的简历
你可能喜欢celery&优先级问题简单记录
是一个简单、灵活且可靠的,处理大量消息的分布式系统,并且提供维护这样一个系统的必需工具。
它是一个专注于实时处理的任务队列,同时也支持任务调度。
优先级队列问题:
官方给出的是不支持优先级队列:http://docs.celeryproject.org/en/master/faq.html#does-celery-support-task-priorities
/priority.html
celery中broker 常用的是rabbitmq,rabbitmq
3.5版本之后支持优先级队列,消息具有不同的优先级,同一个队列中优先级高的先得到处理。rabbitmq
支持这种特性的话,celery就可以实现优先级队列,毕竟celery是从broker中获取msg的。
celery还可以通过rabbitmq中的Consumer
Priorities
的特性支持队列之间的优先级。A和B两个队列,A队列的consumer优先级位10,B队列的consumer优先级位1.那么之后当A队列的consumer都处于阻塞状态的时候,B队列的consumer才能从rabbitmq中获取消费信息。
from kombu import Exchange, Queue
CELERY_QUEUES = (
& & Queue('celery',
Exchange('celery', type='direct'), routing_key='celery',
consumer_arguments={'x-priority': 0}),
& & Queue('hipri',
Exchange('hipri', type='direct'), routing_key='hipri',
consumer_arguments={'x-priority': 10}),
/consumer-priority.html
/celery/celery/issues/3098
已投稿到:
以上网友发言只代表其个人观点,不代表新浪网的观点或立场。celery 守护进程部署之后 django 项目所遇问题 - V2EX
celery 守护进程部署之后 django 项目所遇问题
233 天前 &fanne
部署 celery 的守护进程
参考资料:
拷贝这个文件(
)内容到 /etc/init.d/celeryd
编写项目的 celery 配置文件/etc/default/celeryd
cat /etc/default/celeryd
CELERYD_NODES="djangoCelery1"
CELERY_BIN="/usr/local/python27/bin/celery"
CELERY_APP="ansible_ops"
CELERYD_CHDIR="/my/project"
CELERYD_OPTS="--time-limit=300 --concurrency=4"
CELERY_LOG_LEVEL="DEBUG"
CELERYD_LOG_FILE="/var/log/celery/%n%I.log"
CELERYD_PID_FILE="/var/run/celery/%n.pid"
CELERYD_USER="root"
CELERYD_GROUP="root"
CELERY_CREATE_DIRS=1
启动后一些日志输出:
[ 19:36:50,601: INFO/MainProcess] Received task: items.views.call_shell[c5b52a72-f6da-4b32-8f4e-3bcc]
[ 19:44:39,190: INFO/MainProcess] Connected to redis://localhost:6379/0
[ 19:44:39,197: INFO/MainProcess] mingle: searching for neighbors
[ 19:44:40,213: INFO/MainProcess] mingle: all alone
[ 19:44:40,226: WARNING/MainProcess] /usr/local/python27/lib/python2.7/site-packages/celery/fixups/django.py:202: UserWarning: Using settings.DEBUG leads to a memory leak, never use this setting in production environments!
warnings.warn('Using settings.DEBUG leads to a memory leak, never '
这个算是把 celery 用守护进程部署好了。
django 直接用 python
runserver 启动在 console 控制台上。
用守护进程部署好 celery 后所遇到以下问题
django 的代码片段
@celery_app.task
def call_shell(ipList,add_ipList,shell_dir,shell_file):
nowTime = time.strftime('%Y-%m-%d_%H-%M-%S', time.localtime(time.time()))
print 'dddddddddddddddddddddddddddddd'
print 'dddddddddddddddddddddddddddddd'
print nowTime
shell_log = 'static/searchlog/add_game_log_%s.txt' % nowTime
os.popen(r"echo %s && %s" % (ipList, add_ipList))
p = Popen("cd %s;/bin/sh %s" % (shell_dir, shell_file),stdout=PIPE,stderr=STDOUT,shell=True,bufsize=1)
for line in iter(p.stdout.readline,b''):
shell_log.write(line)
print line
p.stdout.close()
os.popen(r"/bin/sed -i '$d' %s" % add_ipList)
当 celery 用守护进程部署好之后,代码里的
nowTime = time.strftime('%Y-%m-%d_%H-%M-%S', time.localtime(time.time()))
print 'dddddddddddddddddddddddddddddd'
print 'dddddddddddddddddddddddddddddd'
print nowTime
在 console 里和 celery 的日志里都没看到这些 print 信息,然后 shell_log 文件也没有生成。
这是什么个情况的
857 次点击所在节点 &
jkmmmm233 天前你从其他地方调用这个 call_shell 没?另外 console 和 celery 日志里就不应该有这些信息吧,用用 logging 模块。
gulu233 天前print 的东西只有在 celery 控制台才看得到的吧,而且还要设置 --loglevel=info
然后你再去看看 error log
fanne233 天前@ 是在其他地方调用了这个 call_shell 内容的
call_shell.delay(ipList,add_ipList,shell_dir,shell_file)
fanne233 天前@
日志没打印出来,然后我的一个文件也没有生成的
nowTime = time.strftime('%Y-%m-%d_%H-%M-%S', time.localtime(time.time()))
shell_log = 'static/searchlog/add_game_log_%s.txt' % nowTime
正常来说应该会根据调用这个 call_shell 的时候时间生成的一个 shell_log 的文件
for line in iter(p.stdout.readline,b''):
shell_log.write(line)
p.stdout.close()
然后通过 shell_log.write(line)写入到 shell_log 这个文件,但也没有生成。
fanne233 天前@ @ 是我太大意了,代码问题
shell_log = 'static/searchlog/add_game_log_%s.txt' % nowTime
%nowTime 中间带了个空格,下面一些也是,都带了空格了,改正了一下就正常了。
第 1 页 / 共 1 页&
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到
上打开本讨论主题的完整版本。
是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
is a community of developers, designers and creative people.

我要回帖

更多关于 jira问题的工作流 的文章

 

随机推荐