On 06/28/2016 11:34 AM, Martin Häcker wrote:
Hi there,

we're using sqlalchemy from within a tornado application to access the
database. To prevent us from accidentally stopping the single threaded
server we adopted a usage pattern of sqlalchemy where we use it during
startup to load various objects from the db, and then use background
threads to load more as required.

Since we wanted an easy way to get errors when we accidentally break
this pattern, we created a session that will raise when used and
subclassed the ThreadLocalRegistry to make it easy to use it.

Thus now Database access only works like this:

with DatabaseAccess():
   # do something to access the db

and is nicely explicit and raises otherwise.

We'd like to open source this (~100 loc + tests) perhaps as part of
sqlalchemy or the wiki? What do you think, would this be useful to somebody?

I'm not sure I'm understanding what it looks like when you "accidentally break" the pattern. If I could see more of what we're talking about that would help, though it sounds like this is an async-oriented use case. That's fine but external projects for these kinds of things make life a lot easier for me, including it under SQLAlchemy main means I take on the maintenance / support burden.





Best regards,
Martin Häcker

--
You received this message because you are subscribed to the Google
Groups "sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to sqlalchemy+unsubscr...@googlegroups.com
<mailto:sqlalchemy+unsubscr...@googlegroups.com>.
To post to this group, send email to sqlalchemy@googlegroups.com
<mailto:sqlalchemy@googlegroups.com>.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to