Django的交易错误

我有一个cronjob它处理电子邮件,并将它们存储在系统中。 它会一直运作良好一年多了,但现在突然它已经开始随意飘飞给这些奇怪的交易错误。

2010-09-02-01:45:11 ERROR Exception occured during mail processing Traceback (most recent call last): File "/var/www/example.com/project/scripts/cronjobs.py", line 453, in process_msg source, email, 'i' if rejection_reason else 'v', rejection_reason) File "/usr/lib/python2.5/site-packages/django/db/transaction.py", line 267, in _commit_manually leave_transaction_management() File "/usr/lib/python2.5/site-packages/django/db/transaction.py", line 77, in leave_transaction_management raise TransactionManagementError("Transaction managed block ended with pending COMMIT/ROLLBACK") TransactionManagementError: Transaction managed block ended with pending COMMIT/ROLLBACK

它发生,没有任何原因,并没有提供给我任何其他的上下文信息。 这里是我的process_msg功能结构:

@commit_manually def save_email( u,l, d, t, s, e, status, reason): try: # ... bla bla bla ... commit() exception, e: rollback() raise e def process_msg(m): try: #.... save_email(u, l, d, t source, email, 'i' if rejection_reason else 'v', rejection_reason) #.... except Exception, e: logger.error('Error while processing email', exc_info=True ) return None else: return True

如何如何,我探讨这个问题?

--------------解决方案-------------

它看起来好像进入前发生错误save_email() 由于没有commit()rollback() ​​的指令process_msg()一个TransactionError提高。

你可以尝试用调试器以画圈的错误:

def process_msg(m):
try:
import pdb # import python debugger
pdb.set_trace() # begin debugging
#....
save_email(u, l, d, t,
[…]

你可以找到如何使用调试器Python的网站上的信息。

分类:Django的 时间:2015-03-15 人气:1
本文关键词: Django的,交易
分享到:

相关文章

Copyright (C) 55228885.com, All Rights Reserved.

55228885 版权所有 京ICP备15002868号

processed in 0.632 (s). 10 q(s)