From 5d595a1a4311a4a2549a9e18308ce7ab7f147ae2 Mon Sep 17 00:00:00 2001 From: Nicolas Jaremek Date: Tue, 27 Jun 2017 11:50:51 +0200 Subject: [PATCH] Added conditional check on 'atexit' event function: the Python interpreter may remove the '_State' class before running the 'atexit' event actions, which yields a stacktrace with a 'NoneType has no _transation attribute' error. Checking on the existence of the '_State' class, and then on its attributes ensures the NoneType error does not appear. --- scraperwiki/sql.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scraperwiki/sql.py b/scraperwiki/sql.py index 98f1912..65412d1 100644 --- a/scraperwiki/sql.py +++ b/scraperwiki/sql.py @@ -123,7 +123,7 @@ def commit_transactions(): """ Ensure any outstanding transactions are committed on exit """ - if _State._transaction is not None: + if _State is not None and _State._transaction is not None: _State._transaction.commit() _State._transaction = None