[Twisted-Python] Using sqlalchemy in twisted.

luper rouch luper.rouch at gmail.com
Tue Mar 10 13:22:29 EDT 2009


I would recommend sandboxing Twisted code in another process when used
in conjunction with synchronous code (sqlalchemy, GUI, etc...). This
proved quite simple in my project, using the multiprocessing module
[1], and avoided me lots of headaches since.

This way I don't mix coding styles everywhere using deferToThread(),
nor do I care about threads safety madness.

Now I'm not sure if this could apply to your situation, but if like me
you're just routing the SA traffic through Twisted (just guessing as
you mentioned deferToThread()), have not so much interaction between
Twisted and the synchronous code part, it might be a better solution
than writing wrappers / limiting your usage of the synchronous code.

Luper

[1]http://code.google.com/p/python-multiprocessing/ (now part of python 2.6)




More information about the Twisted-Python mailing list