On Thu, Feb 06, 2014 at 12:49:32PM +0000, Michael Rau wrote: > Hello people, > > I observe a strange situation with uwsgi + nginx + flask + sqlalchemy. In > production mode I am running uwsgi with 4 processes and 2 threads. This > application obviously uses simple forms. Now if I make a change to some > form content, committing this into the database everything is fine. But > triggering a reload in the browser brings up the old value. Reloading again > and again brings up the new value. This goes round in circles and it very > much seems to be related to the processes/threads. If I set uwsgi to 1 > process, this behaviour does not occur. > > BTW: I am using sqlalchemy's scoped sessions. > > What am I missing here?
It's hard to tell without seeing the code, but I suspect that it has to do with how you are managing the SqlAlchemy session lifecycle. I guess that your session is not being closed at the end of each request, so that SQL object instances are being cached between requests. Here's a pertinent section of the SqlAlchemy docs: http://docs.sqlalchemy.org/en/rel_0_9/orm/session.html#when-do-i-construct-a-session-when-do-i-commit-it-and-when-do-i-close-it I don't know enough about flask to say how you might go about doing this. In pyramid, for example, you would most likely use a "tween" to commit or rollback the session, then close it at the end of each request. (Or use the transaction, zope.sqlalchemy, and pyramid_tm packages which together would do this for you.) _______________________________________________ uWSGI mailing list [email protected] http://lists.unbit.it/cgi-bin/mailman/listinfo/uwsgi
