diff --git a/pscheduler-server/pscheduler-server/api-server/pschedulerapiserver/dbcursor.py b/pscheduler-server/pscheduler-server/api-server/pschedulerapiserver/dbcursor.py index 7819061f5..e99199e7d 100644 --- a/pscheduler-server/pscheduler-server/api-server/pschedulerapiserver/dbcursor.py +++ b/pscheduler-server/pscheduler-server/api-server/pschedulerapiserver/dbcursor.py @@ -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,