On Jul 18, 2006, at 4:57 AM, Julien Cigar wrote: > Ok, I will try the association object, it looks better ! > > Another question, I'm using SQLAlchemy with mod_python. That means > that a Python interpreter is loaded in each apache process (in > prefork mode). In my application I use a global session object per > process (which is not threadsafe, but.. I use the prefork mode at > the moment :)), so I have at least 5 sessions running in parallel > (at least 5 Apache processes). I noticed that if I don't do a > session.expunge(an_object) after a session.flush(), some older > instances of an_object live in other processes (for example I have > to do some refresh if I don't use session.expunge). > This is quite logical I think, a process cannot know what's > happened in another processes (different Python interpreters), but > I wondered if the way I'm doing is the "best" way ? >
the session represents your current workspace of objects for a request...so yah each process is on its own as far as session management. you probably want to use a new session per request, or clear() the session at the beginning and/or end of each request so you reload everything from the database each time (i.e. dont use the session as an across-request cache). ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ Sqlalchemy-users mailing list Sqlalchemy-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users