I am currently using SQLAlchemy with Twisted with deferToThread and it works rather well, have you tried it? So long as you create a new session for each thread you spawn (which you should also do without Twisted) it works without any modification required.
Here's an example of using SQLAlchemy with Twisted— no guarantees on it's the
best way to do things, but it works.
def checkIfNodeExists(nodeId):
def threadFunction():
s = Session()
r = s.query(Node).filter(Node.NodeId == nodeId).count()
if r is not 0:
return True
else:
return False
return threads.deferToThread(threadFunction)
On Aug 21, 2013, at 9:05 PM, Jonathan Vanasco <[email protected]> wrote:
>
> It would be really beneficial if this were something that fully works with
> twisted, but is not dependent on it.
>
> For example, I have a "Project" that mostly uses SqlAlchemy. It started out
> in Pylons, new development is on Pyramid and there are additional tasks in
> Celery + some more in Twisted. Aside from a few manual db tasks in Twisted,
> they all share and re-use a common "Model" package.
>
> Having a great ORM for twisted is wonderful , but its way less exciting and
> attractive if it's only for twisted.
> _______________________________________________
> Twisted-Python mailing list
> [email protected]
> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________ Twisted-Python mailing list [email protected] http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
