[Twisted-Python] SQLAlchemy and Twisted
Chris Withers
chris at simplistix.co.uk
Wed May 5 10:07:05 MDT 2010
Doug Farrell wrote:
>
> I’ve been doing some searching about how to get SQLAlchemy and Twisted
> working together in a Twisted application.
Short version: to be safe, anything that touches any SQLAlchemy-mapped
object needs to be run in its own thread. Any query or access of an
attribute of a mapped object may result in a blocking sql query. (aka:
twisted doesn't play nice with orms)
> definitive answer. The most promising one I’ve run across concerns
> running the SQLAlchemy queries in a separate process (rather than a
> separate thread) and communicating the queries between the Twisted
> application in one process and the SQLAlchemy application in another.
That seems a little odd.
What would be the IPC?
How would the "sqlachemy application" be run?
> 1) Would the SQLAlchemy process also be a Twisted application with
> all the queries running as deferreds in the main thread, and blocking?
What do you men by "all the queries"?
> Thanks in advance for any help!
In my case, since most of the app I'm working on is "web requested"
(either xmlrpc or http), I just agve up and used a good wsgi stack
(repoze.bfg in my case) and munge other incoming requests into wsgi
requests.
Twisted's wsgi server runs each request in its own thread, so be it.
cheers,
Chris
More information about the Twisted-Python
mailing list