Skip to content

Commit

Permalink
Properly cache thread-local database connection object. #1466
Browse files Browse the repository at this point in the history
  • Loading branch information
mfeit-internet2 committed Aug 30, 2024
1 parent 3ac8ca1 commit 099f451
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,12 @@ def cursor(self):

def dbcursor():
"""Get this thread's database cursor"""
return getattr(module.threadlocal, "cursor", DBCursor()).cursor()
try:
cursor = getattr(module.threadlocal, 'cursor')
except AttributeError:
cursor = DBCursor()
setattr(module.threadlocal, 'cursor', cursor)
return cursor.cursor()


def dbcursor_query(query,
Expand Down

0 comments on commit 099f451

Please sign in to comment.