[Twisted-Python] SQLAlchemy and Twisted

Konrads Smelkovs konrads.smelkovs at gmail.com
Fri May 7 04:53:30 MDT 2010


If you want an ORM in Twisted look for STORM twisted integration. Overall,
it works (I tried). Some quirks are there, e.g. without twisted you would do
something like resultset[10:20].sort(Sort.ASC) but with twsited you have to
do (assuming inlineCallbacks)

res= yield  resultset[10:20]
res = yield res.sort(Sort.ASC)

which ain't pretty but it sure beats using plain twisted.enterprise
--
Konrads Smelkovs
Applied IT sorcery.


On Thu, May 6, 2010 at 11:00 PM, Kevin Horn <kevin.horn at gmail.com> wrote:

> You might also check out sAsync: http://sasync.org/
>
> This was a project apparently abandoned (?) by the original author, but
> it's recently been picked up by someone else.
>
> Kevin Horn
>
>
> On Thu, May 6, 2010 at 2:04 PM, César García <celord at gmail.com> wrote:
>
>> Guys, now that I see this and the past conversations about SA and Twisted,
>> and now that I've read some more about the non-blocking concepts, I think
>> that I'am not doing things the best way
>>
>>  I am doing this:
>>
>> 1. Twisted  IMAP4 Client to read my mails
>> 2. Inside this client I import a module that contains some funtions that
>> parse the email via re
>> 3. Also inside the client I import a module that makes a DB connection and
>> insert the data parsed from those emails, all this via SQL using mapped
>> tables.
>>
>> I'm almost sure that I'm breacking the hole twisted concept doing this
>> thisway , do you guys have any advice for me
>>
>> Thanks
>> 2010/5/5 Chris Withers <chris at simplistix.co.uk>
>>
>> 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
>>>
>>>
>>> _______________________________________________
>>> Twisted-Python mailing list
>>> Twisted-Python at twistedmatrix.com
>>> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
>>>
>>
>>
>>
>> --
>> http://celord.blogspot.com/
>>
>> _______________________________________________
>> Twisted-Python mailing list
>> Twisted-Python at twistedmatrix.com
>> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
>>
>>
>
> _______________________________________________
> Twisted-Python mailing list
> Twisted-Python at twistedmatrix.com
> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: </pipermail/twisted-python/attachments/20100507/f7844883/attachment-0001.html>


More information about the Twisted-Python mailing list