From d5d9330b82d14c5930a8c6af99e84257f33e9e05 Mon Sep 17 00:00:00 2001 From: Alan Hamlett Date: Wed, 24 Jun 2020 08:31:47 -0700 Subject: [PATCH] Prevent AttributeError when listeners not present on Flask.g --- nplusone/ext/flask_sqlalchemy.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nplusone/ext/flask_sqlalchemy.py b/nplusone/ext/flask_sqlalchemy.py index d9ef2f3..5c14fd6 100644 --- a/nplusone/ext/flask_sqlalchemy.py +++ b/nplusone/ext/flask_sqlalchemy.py @@ -48,7 +48,7 @@ def connect(): @app.after_request def disconnect(response): for name in six.iterkeys(listeners.listeners): - listener = g.listeners.pop(name, None) + listener = g.get('listeners', {}).pop(name, None) if listener: listener.teardown() return response