【问题标题】:Celerycam error - This code isn't under transaction managementCelerycam 错误 - 此代码不在事务管理下
【发布时间】:2013-11-19 22:07:42
【问题描述】:

我的设置包括 django 1.5.1、celery 3.1.0 和 redis 作为后端

$ python manage.py celerycam -b 'redis://localhost:6379/0'

使 celerycam 运行,但它不断发出以下错误:

TransactionManagementError: This code isn't under transaction management
[2013-11-19 15:19:44,097: ERROR/MainProcess] Error in timer: TransactionManagementError("This code isn't under transaction management",)
Traceback (most recent call last):
  File "/Users/andres/.virtualenvs/rpmwest/lib/python2.7/site-packages/kombu/async/timer.py", line 166, in apply_entry
entry()
  File "/Users/andres/.virtualenvs/rpmwest/lib/python2.7/site-packages/kombu/async/timer.py", line 64, in __call__
return self.fun(*self.args, **self.kwargs)
  File "/Users/andres/.virtualenvs/rpmwest/lib/python2.7/site-packages/kombu/async/timer.py", line 127, in _reschedules
return fun(*args, **kwargs)
  File "/Users/andres/.virtualenvs/rpmwest/lib/python2.7/site-packages/celery/events/snapshot.py", line 73, in capture
self.state.freeze_while(self.shutter, clear_after=self.clear_after)
  File "/Users/andres/.virtualenvs/rpmwest/lib/python2.7/site-packages/celery/events/state.py", line 293, in freeze_while
return fun(*args, **kwargs)
  File "/Users/andres/.virtualenvs/rpmwest/lib/python2.7/site-packages/celery/events/snapshot.py", line 70, in shutter
self.on_shutter(self.state)
  File "/Users/andres/.virtualenvs/rpmwest/lib/python2.7/site-packages/djcelery/snapshot.py", line 129, in on_shutter
transaction.commit()
  File "/Users/andres/.virtualenvs/rpmwest/lib/python2.7/site-packages/django/db/transaction.py", line 152, in commit
connection.commit()
  File "/Users/andres/.virtualenvs/rpmwest/lib/python2.7/site-packages/django/db/backends/__init__.py", line 242, in commit
self.set_clean()
  File "/Users/andres/.virtualenvs/rpmwest/lib/python2.7/site-packages/django/db/backends/__init__.py", line 184, in set_clean
raise TransactionManagementError("This code isn't under transaction management")
TransactionManagementError: This code isn't under transaction management
[2013-11-19 15:19:45,010: WARNING/MainProcess] Substantial drift from celery@Lyn.local may mean clocks are out of sync.  Current drift is
50400 seconds.  [orig: 2013-11-19 15:19:45.010442 recv: 2013-11-19 01:19:45.009564]

【问题讨论】:

  • 我在 Django 1.4.8 中遇到了同样的问题。你找到解决方案了吗?我的直觉是,这可能是由于 Django 交易,众所周知,这些交易不是 100% 可靠的。据说它在 Django 1.6 上要好得多,这让我认为最新的 kombu/celery 仅针对此设置进行了测试?
  • 嗯,很奇怪。我将尝试升级到 Django 1.6,看看它是否有效。

标签: python django celery django-celery


【解决方案1】:

您是否遵循了 django/celery 集成的新指南? http://docs.celeryproject.org/en/master/django/first-steps-with-django.html

我将我的项目转换为不再调用 djcelery.setup_loader() 而是现在在 {project}/{project}/celery.py 下有一个 celery.py

还有你的 CELERY_RESULT_BACKEND 设置是什么?我的设置为 djcelery.backends.database:DatabaseBackend

你的大时钟漂移可能与它有关吗?您是否尝试过同步时钟?

我正在使用 celerycam 运行 django 1.6.1,没有任何问题。

【讨论】:

    猜你喜欢
    • 2013-03-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-30
    • 2021-11-09
    • 2020-07-20
    相关资源
    最近更新 更多