can't get pool_recycle to prevent "gone away" errors

530 views
Skip to first unread message

jeffcodefork

unread,
Oct 23, 2007, 1:36:52 PM10/23/07
to sqlalchemy
Hi,

I'm running SA 0.4 on 3 instances of cherrypy, each with 10 threads.
Each thread creates its own Session object when it initializes, and
reuses the Session continually. This is what my SA init code looks
like:


db = sa.create_engine("mysql://%s:%s@%s/%s" % (DBUSER, DBPASSWORD,
DBHOST, DBINSTANCE), pool_size=40, pool_recycle=3600, max_overflow=2)

Session = orm.sessionmaker(bind=db, autoflush=True,
transactional=True)


After leaving the dev server alone overnight, it comes up with the
error:

OperationalError: (OperationalError) (2006, 'MySQL server has gone
away')

Am I using pool_recycle incorrectly, or is there something else I
should be doing to ensure Session pulls a good connection from the
pool?

Thanks for any help or suggestions. SA is mindblowingly amazing.

Jeff

Michael Bayer

unread,
Oct 23, 2007, 4:44:12 PM10/23/07
to sqlal...@googlegroups.com

you'd have to close() the Session when youre done with it, or just
discard it; with a transactional=True session, its going to hold on
to a connection persistently. you can turn on echo_pool=True to view
connection checkout activity.

jeffcodefork

unread,
Oct 23, 2007, 7:11:00 PM10/23/07
to sqlalchemy
Yes! That's it.

Thanks so much,
Jeff

Reply all
Reply to author
Forward
0 new messages