Skip to content

Commit 5d595a1

Browse files
committed
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.
1 parent eac9883 commit 5d595a1

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

scraperwiki/sql.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ def commit_transactions():
123123
"""
124124
Ensure any outstanding transactions are committed on exit
125125
"""
126-
if _State._transaction is not None:
126+
if _State is not None and _State._transaction is not None:
127127
_State._transaction.commit()
128128
_State._transaction = None
129129

0 commit comments

Comments
 (0)