Skip to content

Commit

Permalink
Add pool_size and only create 1 engine/factory
Browse files Browse the repository at this point in the history
  • Loading branch information
keiranjprice101 committed Aug 2, 2019
1 parent 85304fc commit beb9df8
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions common/session_manager.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker, scoped_session
from sqlalchemy.pool import QueuePool

from common.constants import Constants

engine = create_engine(Constants.DATABASE_URL, poolclass=QueuePool, pool_size=100, max_overflow=0)
session_factory = sessionmaker(engine)


class SessionManager(object):

def __init__(self):
self.engine = create_engine(Constants.DATABASE_URL, pool_size=1000)
self.session_factory = sessionmaker(bind=self.engine)
self.Session = scoped_session(self.session_factory)
self.Session = scoped_session(session_factory)

def get_icat_db_session(self):
"""
Expand Down

0 comments on commit beb9df8

Please sign in to comment.