human
Complete this python program:
def close_db_connections(func, *args, **kwargs):
assistant
#Here is the Python code you requested.

    """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