Hello,

I've been unable to shake 'MySQL has gone away' errors in my application. 
 Here's my setup:

It's a pretty classic REST API built on top of Flask and MySQL with a 
scoped_session

engine = create_engine('mysql+mysqldb:/********', 
                        convert_unicode=True, 
                        pool_size=3, 
                        pool_recycle=60)
db_session = scoped_session(sessionmaker(autocommit=False,
                                         autoflush=False,
                                         bind=engine))

However, I also have another component of the project that runs 
continuously in the background and occasionally acts upon the same data 
model.  Its using the same session initialization code. Basically, every 
couple seconds I check the data model and occasionally spawn off a new 
thread that retrieves external data and updates the database accordingly. 
 I assumed that scoped_session would just handle all this automatically, 
but I'm getting 'Gone Away' errors and mysql processlist seems to show that 
the connections are not being recycled (as this goes on I rack up more 
connections and their times do not reset).  I've tried a variety of pool 
sizes and recycle intervals.

Thanks for your help,
Lucas

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/sqlalchemy/-/Dx6sf4Xa_ZAJ.
To post to this group, send email to sqlalchemy@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to