Skip to content

Commit

Permalink
close db session when class closes, WIP #119
Browse files Browse the repository at this point in the history
  • Loading branch information
cooperq committed Mar 31, 2021
1 parent 9dbecf2 commit 99bab3a
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/api_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ def __init__(self, args):
self.logger = args.logger
self.config = args.config

def __del__(self):
self.db_session.close()

def user_tower_count(self, project, api_key):
if ApiTower.query.filter(ApiTower.api_key == api_key).filter(ApiTower.project == project).count():
tower = ApiTower.query.filter(ApiTower.api_key == api_key).filter(ApiTower.project == project).order_by(ApiTower.ext_id.desc())[0]
Expand All @@ -36,7 +39,6 @@ def add_towers(self, api_key, project, towers):
t = ApiTower(**tower)
self.db_session.add(t)
self.db_session.commit()
#self.db_session.close()
delta_tc = self.all_tower_count() - old_tc

return (delta_tc, self.user_tower_count(project, api_key))
Expand All @@ -53,7 +55,6 @@ def add_user(self, name, contact, description):

self.db_session.add(user)
self.db_session.commit()
#self.db_session.close()
return user

def is_key_authorized(self, api_key):
Expand Down

0 comments on commit 99bab3a

Please sign in to comment.