Multiple request in the same controller causing problems with SQLAlchemy Session object

17 views
Skip to first unread message

Alan Castro

unread,
Nov 9, 2010, 4:56:21 PM11/9/10
to sqlalchemy
Hello,

Latelly I've been running into this issue:

OperationalError: (OperationalError) (2013, 'Lost connection to MySQL
server during query') SELECT...

To contextualize, I developed a Pylons application using
scoped_session (default in pylons). And it was working until I created
some extra processes of my application.

Thanks

Alan

Michael Bayer

unread,
Nov 9, 2010, 5:05:50 PM11/9/10
to sqlal...@googlegroups.com

DBAPI connections don't travel well over process boundaries. You need to call create_engine() inside each new child process.

>
> Thanks
>
> Alan
>
> --
> You received this message because you are subscribed to the Google Groups "sqlalchemy" group.
> To post to this group, send email to sqlal...@googlegroups.com.
> To unsubscribe from this group, send email to sqlalchemy+...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
>

Warwick Prince

unread,
Nov 9, 2010, 5:10:59 PM11/9/10
to sqlal...@googlegroups.com
Hi Alan

We're also doing battle with this one.. One thing I did find was if I had large(ish) BLOB values, MySQL would go away. I found that I had to tweak some settings on MySQL to allow for larger sizes. (The default settings appear to be ridiculously small). Let me know what else you find, as it is a very annoying issue for us as well. BTW: What connector are you using?

Cheers
Warwick


Warwick Prince
Managing Director
mobile: +61 411 026 992
skype: warwickprince

phone: +61 7 3102 3730
fax: +61 7 3319 6734
web: www.mushroomsys.com

Alan Castro

unread,
Nov 9, 2010, 8:08:04 PM11/9/10
to sqlalchemy
Hi guys,

An update: Mike is right! The connector doesn't get along with child
processes... For a quick setup and since I'm using uWSGI and Nginx, I
just created a cluster o uwsgi connections and ran 3 independent
process of my application. All my tests passed nicely.

@Warwick I'm using mysql-python (MySQLdb). And try to follow what Mike
said and test it and see if you still get the errors.

Tomorrow I'll run more tests at work but I think it is solved.

Thanks Mike!

Regards

Alan
Reply all
Reply to author
Forward
0 new messages