retry.py 文件源码

python
阅读 28 收藏 0 点赞 0 评论 0

项目:websauna 作者: websauna 项目源码 文件源码
def ensure_transactionless(msg=None, transaction_manager=transaction.manager):
    """Make sure the current thread doesn't already have db transaction in process.

    :param transaction_manager: TransactionManager to check. Defaults to thread local transaction manager.
    """

    txn = transaction_manager._txn

    if txn:
        if not msg:
            msg = "Dangling transction open in transaction.manager. You should not start new one."

        transaction_thread = getattr(transaction.manager, "begin_thread", None)
        logger.fatal("Transaction state management error. Trying to start TX in thread %s. TX started in thread %s", threading.current_thread(), transaction_thread)

        # Destroy the transaction, so if this was a temporary failure in long running process, we don't lock the process up for the good
        txn.abort()

        raise TransactionAlreadyInProcess(msg)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号