Skip to content

Commit

Permalink
Merge pull request #109 from cs50/develop
Browse files Browse the repository at this point in the history
disconnecting only if there's a connection
  • Loading branch information
Kareem Zidane authored Jan 13, 2020
2 parents d1e5ff7 + c0b24da commit 1689322
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 1689322

Please sign in to comment.