Skip to content

Commit

Permalink
disconnecting only if there's a connection
Browse files Browse the repository at this point in the history
  • Loading branch information
Kareem Zidane committed Jan 13, 2020
1 parent c73587b commit c0b24da
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@
package_dir={"": "src"},
packages=["cs50"],
url="https://github.com/cs50/python-cs50",
version="5.0.1"
version="5.0.2"
)
3 changes: 2 additions & 1 deletion src/cs50/sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,8 @@ def execute(self, sql, *args, **kwargs):
# Disconnect later
@flask.current_app.teardown_appcontext
def shutdown_session(exception=None):
flask.g._connection.close()
if hasattr(flask.g, "_connection"):
flask.g._connection.close()

# Use this connection
connection = flask.g._connection
Expand Down

0 comments on commit c0b24da

Please sign in to comment.