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?
--
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.