On Feb 10, 2011, at 6:05 AM, Romy wrote:

> On Feb 7, 7:24 am, Michael Bayer <[email protected]> wrote:
>> My recommendation would be to call scopedsession.remove() at the end of a 
>> request.  Though with an "async" server like Tornado, though I haven't used 
>> it, I'm not sure that "thread local" sessions, that is the default behavior 
>> of a "scopedsession", are even appropriate - you'd need to devise some way 
>> to link a specific Session to a request, and when that request is over, 
>> simply close() that Session.
> 
> Don't see why that should be a problem. Both sync and async functions
> all eventually call a finish() method, which is where I've added an
> elixir.session.remove(), with elixir.session being a scopedsession.
> Seems to be working fine so far.
> 
>> Perhaps i should add a note to that documentation section that this assumes 
>> a synchronous, possibly multi-threaded web application.
>> 
>> In your case your goal should be to 1. consider a single Session's life span 
>> as a single transaction with the database and 2. ensure that you have one 
>> and only one transaction per request, not shared with any other request.    
>> If you are sharing a single transaction with multiple requests, that would 
>> quickly lead to errors of the kind you are describing.
> 
> I'm not sharing transactions, but why can I only have one transaction
> per request ?

sorry, more clear, don't share one transaction with multiple requests.      few 
transactions per individual request is better too but not a requirement.



-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to