[Twisted-Python] Running CPU bound function concurrently in twisted

Chengi Liu chengi.liu.86 at gmail.com
Mon Jun 24 12:34:03 MDT 2019


Thanks for pointing that out. Is there a dead simply example on how to
parallelize a function using ampoule.
Again, I have a function.. I have a for loop.. the function takes in an
argument from loop.. but the for loop is extremely parallelizable.

Also, I was going thru this awesome twisted tutorial from pycon 2107 (
https://www.youtube.com/watch?v=ztkBG4qLR_4)
I found couple of use features.
(defer.ensureDeferred
and

defer.gatherResults

)
Can these two be used instead of deferToThread.
When are the above defered used and when to use deferToThread.

Thanks for entertaining my dumb questions.

On Mon, Jun 24, 2019 at 1:28 AM Gelin Yan <dynamicgl at gmail.com> wrote:

> Hi
>
>    If your purpose is merely not to block the reactor, you can run your
> code in a separate thread by using deferToThread. If you want to benefit
> from multi cores, you may consider use https://github.com/twisted/ampoule
> or other similar tools.
>
> Regards
>
> gelin yan
> _______________________________________________
> Twisted-Python mailing list
> Twisted-Python at twistedmatrix.com
> https://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: </pipermail/twisted-python/attachments/20190624/055808b0/attachment-0002.html>


More information about the Twisted-Python mailing list