[Twisted-Python] Twisted synchronous and asynchronous db connections

exarkun at twistedmatrix.com exarkun at twistedmatrix.com
Mon Nov 9 20:43:18 MST 2009


On 03:24 am, doug.farrell at gmail.com wrote:
>Hi all,
>
>Our projects at work include synchronous applications (short lived)
>and asynchronous Twisted applications (long lived). We're re-factoring
>our database and are going to build an API module to decouple all of
>the SQL in that module. I'd like to create that API so both
>synchronous and asynchronous applications can use it. For the
>synchronous applications I'd like calls to the database API to just
>return data (blocking) just like using MySQLdb, but for the
>asynchronous applications I'd like calls to the same API
>functions/methods to be non-blocking, probably returning a deferred.
>Anyone have any hints, suggestions or help they might offer me to do
>this?

Chris Armstrong wrote a synchronous implementation of Deferred.  That 
might be an approach to investigate:

  http://radix.twistedmatrix.com/2007/12/supporting-both-asynchronous- 
and.html

Jean-Paul




More information about the Twisted-Python mailing list