Closed raphaelfeng closed 3 months ago
Hello!
We have not had problems with this because the way we use this in microcosm-flask
is not threaded.
Do you have any sample code that causes issues with sessions and threading? I see how what you're describing would cause problems, but for the overall health of the ecosystem, we would like to know how exactly you are using microcosm-postgres
in a multi-threaded environment for more context.
Thanks for the quick reply.
The threaded
option is enabled by default in flask 1.1.0 https://github.com/pallets/flask/blob/1.1.0/src/flask/app.py#L941. So it can cause issue when using with flask's default option.
Can you give me some specific repro steps/problem statement? We've been using this library for years now and haven't run into any issues with threading, although perhaps you've found an issue we ourselves have encountered but didn't realize the root cause for.
The session is a class variable, so if
SessionContext.session would be None to thread b.
Can we use scoped session as described in https://docs.sqlalchemy.org/en/13/orm/contextual.html?