【发布时间】: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