On Sat, May 07, 2011 at 04:49:22PM +0800, Dfgqq Dfgqq wrote: > Hi all > > I have a function like: > > def longQuery(xxx) > > this function will be invoked simultaneously (it means multiple thread > environment) and this function may take a while to complete. > > so my question is whether i should use reactor.callInThread to take benefit > from non blocking
briefly you should use `callInThread` in two cases: when your code does some long computation and when you use some libraries that do network communication in a blocking manner. > or use deferred object ? > > It seems that deferred object doens't use threads. http://twistedmatrix.com/documents/current/core/howto/gendefer.html#auto2 If `longQuery` is a DB query you should look at twisted.enterprise.adbapi http://twistedmatrix.com/documents/current/core/howto/rdbms.html m. -- La vera terra dei barbari non è quella che non ha mai conosciuto l'arte, ma quella che, disseminata di capolavori, non sa nè apprezzarli nè conservarli. -- Marcel Proust _______________________________________________ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python