models.py 文件源码

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

项目:paas-tools 作者: imperodesign 项目源码 文件源码
def close_db_connections(func, *args, **kwargs):
    """
    Decorator to explicitly close db connections during threaded execution

    Note this is necessary to work around:
    https://code.djangoproject.com/ticket/22420
    """
    def _close_db_connections(*args, **kwargs):
        ret = None
        try:
            ret = func(*args, **kwargs)
        finally:
            from django.db import connections
            for conn in connections.all():
                conn.close()
        return ret
    return _close_db_connections
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号