[Twisted-Python] locking threads when deferToThread is used
marian.schubert at gmail.com
Wed Aug 8 08:27:05 EDT 2007
On 8/8/07, Ladislav Andel <ladaan at iptel.org> wrote:
> > Don't. Don't share state between different threads. If you need to
> > mutate
> > state as a result of code which has run in a thread, do it in the reactor
> > thread based on the result of the Deferred returned by deferToThread.
> I'm aiming to use results of the Deffered returned by deferToThread.
> Can you give me an example of combining two Deferred results?
> This will be done through callbacks but what if the blocking application
> gives me result in 5 sec
> and e.g. DNS check in 1 sec.
check gatherResults from twisted.internet.defer. basicaly it's:
d3 = defer.gatherResults(d1, d2)
where d1 is call to blocking app using deferToThread and d2 is DNS check
and d3 gets called back with results of d1 and d2 (if they both succeeded)
More information about the Twisted-Python