From cad0ad02dbdc2d69c0a9b338bec5ed2162672b73 Mon Sep 17 00:00:00 2001 From: Johan De Taeye Date: Mon, 9 Dec 2024 16:48:50 +0100 Subject: [PATCH] set_roll_back should only rollback initialized connections The exception handler call "connections.all()". This creates a database connection to all defined databases. As a small optimization you can use "connections.all(initialized_only=True)" to rollback only the database to which the current thread has open connections. (My application can have many databases defined, and this loop is identified as a source of many idle database connections) --- rest_framework/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rest_framework/views.py b/rest_framework/views.py index 327ebe9032..21b7dd4d3e 100644 --- a/rest_framework/views.py +++ b/rest_framework/views.py @@ -64,7 +64,7 @@ def get_view_description(view, html=False): def set_rollback(): - for db in connections.all(): + for db in connections.all(initialized_only=True): if db.settings_dict['ATOMIC_REQUESTS'] and db.in_atomic_block: db.set_rollback(True) pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy