Skip to content

Commit

Permalink
Issue 1466 (#1471)
Browse files Browse the repository at this point in the history
* Closing branch

* Properly cache thread-local database connection object.  #1466

* Check cursor closed attribute correctly.  #1466

* Don't let leaky API processes live longer than 30 minutes.  #1466

* Remove closed branch file from earlier mistake

---------

Co-authored-by: Andy Lake <[email protected]>
  • Loading branch information
mfeit-internet2 and arlake228 authored Sep 4, 2024
1 parent 6510d0e commit de48184
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ WSGIDaemonProcess __USER_NAME__ \
\
processes=10 \
maximum-requests=1000000 \
graceful-timeout=300

graceful-timeout=300 \
restart-interval=1800 \
inactivity-timeout=600

WSGIScriptAlias __API_ROOT__ __API_DIR__/__NAME__.wsgi

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def cursor(self):

# Make sure we have a cursor.

if self.ccursor is None or self.ccursor.closed():
if self.ccursor is None or self.ccursor.closed:
self.ccursor = self.db.cursor()

return self.ccursor
Expand All @@ -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 de48184

Please sign in to comment.