Yeah. And it turned out that the approach with scoped sessions was
perfectly right. Actually I found out that I was missing one key part:
@app.teardown_appcontext
def shutdown_session(exception=None):
db_session.remove()
And this finally resolved the problem.
RTFM is what I have to say to myself.
Thanks.
Michael.
2014-02-06 19:28 GMT+00:00 Igor Katson <[email protected]>:
> Well, in the same part of the docs, it's also said, that you can use
> Contextual/Thread-local sessions, explaining how to do that
> http://docs.sqlalchemy.org/en/latest/orm/session.html#unitofwork-contextual
>
>
> On Thu, Feb 6, 2014 at 10:33 AM, Michael Rau <[email protected]> wrote:
>
>> 2014-02-06 17:50 GMT+00:00 Jeff Dairiki <[email protected]>:
>>
>> 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.)
>>>
>>
>> Actually flask + sqlalchemy integration clearly says, that the session is
>> managed in the background. BUT the link you provided provided me with
>> another thing. It says:
>>
>> > Is the session thread-safe?
>> > The Session is very much intended to be used in a non-concurrent
>> fashion, which usually means in only one thread at a time.
>>
>> So I set uwsgi options to
>>
>> + processes = 4
>> + threads = 1
>>
>> and that worked. So actually it wasn't the processes, it was the number
>> of threads. Best practice obviously is to work with max. 1 thread under
>> uwsgi + flask + sqlalchemy.
>>
>> Thank you very much for your support!
>>
>> Michael.
>>
>> _______________________________________________
>> uWSGI mailing list
>> [email protected]
>> http://lists.unbit.it/cgi-bin/mailman/listinfo/uwsgi
>>
>>
>
> _______________________________________________
> uWSGI mailing list
> [email protected]
> http://lists.unbit.it/cgi-bin/mailman/listinfo/uwsgi
>
>
--
Michael Rau
Sarasatestraße 61
D-81247 München
Telefon: +49(0) 89-3584-7665
Mobil: +49(0) 176-6162-8248
Fax: +49 (0) 3212-116719
skype: michael_rau_de
mailto: [email protected]
_______________________________________________
uWSGI mailing list
[email protected]
http://lists.unbit.it/cgi-bin/mailman/listinfo/uwsgi