[Twisted-Python] Twisted synchronous and asynchronous db connections
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? Thanks in advance, Doug
On 03:24 am, doug.farrell@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
Jean-Paul,
Thanks for the link, I'm looking at it right now.
Doug
On Mon, Nov 9, 2009 at 10:43 PM,
On 03:24 am, doug.farrell@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
_______________________________________________ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
participants (2)
-
Doug Farrell
-
exarkun@twistedmatrix.com