hello all :)
from the past years, i've been working on solutions to the
"problem" described by Jean (we are co-workers, and we use twisted
and sqlalchemy, A LOT), and as everybody may already know, it's a
very complicated combination, since we have to do a lot of code
around to have a consistent application.
ok, that's not bad, but ... since we are a team of several
developers, from 'grey haired pythonistas' to 'fishes in a
barrel', it's hard to mantain a quality standard, so we decided to
take ALL our codebase based on twisted and sqlalchemy to give it a
try on creating a better integration between them, specially if
you are more acquainted to asynchronous programming.
RESULTS
- we were able to create an "asynchronous" sqlalchemy, but it
relies on deep object copy, so every promise (or deferred, on
twisted's language) generates an overhead that is not welcome
in our standards (or every programmer with a brain, lol);
- without deep copy, furthermore we were able to have again a
fully promise version of sqlalchemy, but we had to left aside
all the ORM codebase and work only with low level sqlalchemy.
that's a good result, but again, we'll have a problem with the
fishes not using the ORM.
THE PROBLEM
SO, after reading a lot about the internals of sqlalchemy AND tons
of solutions out there (sAsync, etc, etc) we always ended up with
the same problem: thread safety. the orm design of sqlalchemy,
specially the session states, are all designed to be thread safe
(Mike, correct me if i'm wrong), so from there the work might be
huge, but we are willing to work on a solution - specially if our
main rdbms, postgres, have one (if not the best) of dialects
implementations in sa. this solution we expect even to publish for
others to use :)
THREAD SAFETY
ok, as Jean already stated (those are actually my words) that
99,9% of the programmers who uses sqlalchemy are quite happy with
the solutions it already provides, which are in fact very, very
usable. we have no problem with that.
but, what if we want to go further on this? i mean, we can already
control a lot of things in sqlalchemy. i mean, a lot, really. it
is very flexible in almost all aspects. but ... why it isn't when
the subject is the session state? or it is and we are missing
something?
FINAL THOUGHTS
the bottom line is not about twisted, just to be clear, but to
implement a non thread safe session state system that can work
with async frameworks (gevent, twisted, tornado) and so on. is
that really possible?
my best regards,
richard.