def __enter__(self):
if len(self.hooks) > 0:
# Capture a textual description of the hooks to help us understand
# why this is about to blow oodles of egg custard in our faces.
description = "\n".join(gen_description_of_hooks(self.hooks))
# Crash when there are orphaned post-commit hooks. These might
# only turn up in testing, where transactions are managed by the
# test framework instead of this decorator. We need to fail hard
# -- not just warn about it -- to ensure it gets fixed.
self.reset()
raise TransactionManagementError(
"Orphaned post-commit hooks found:\n" + description)
评论列表
文章目录