четверг, 20 июня 2013 г., 21:52:37 UTC+3 пользователь Michael Bayer написал: > > > On Jun 18, 2013, at 6:09 PM, graf <[email protected] <javascript:>> > wrote: > > I use SQLAlchemy inside Tornado, and I use a singleton to make the > Firebird connection inside application. > > class FirebirdDatabase(object): > > def __init__(self, firebird_params, echo=False): > engine = create_engine(' > firebird+fdb://%(user)s:%(password)s@%(host)s:%(port)s/%(path)s' % > firebird_params, > echo=echo, > echo_pool=echo, > pool_recycle=3600, > convert_unicode=True, > encoding='cp1251') > self._session = sessionmaker(bind=engine) > > _instance = None > > def __new__(cls, *args, **kwargs): > if not cls._instance: > cls._instance = super(FirebirdDatabase, cls).__new__(cls, > *args, **kwargs) > return cls._instance > > def get_session(self): > return self._session() > > > After a while the Oldest transaction begin blocking and this slow down the > database speed. > > To commit changes I use: > > try: > self.Session.commit() > except InvalidRequestError: > self.Session.rollback() > self.Session.commit() > self.Session.close() > > What I'm doing wrong? Is it wrong way to close Firebird transaction? > > > > I haven't worked with Tornado but the point of it is that you can have > many concurrent requests happening simultaneously in one thread. So you > wouldn't be able to use a global singleton for that, you'd need to have a > Session for each request. > > > Any way the problem is not related to singleton. As far as I understand the Session creates the transaction after first commit/rollback/close and this locks the Oldest transaction and after a while slow down the db speed. "sweep" don't help in this situation. I can't restart my application to remove lock because it is 24/7.
-- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/groups/opt_out.
