Re: Running CPU bound function concurrent ly in twisted

"Moshe Zadka" <[email protected]> Mon, 24 Jun 2019 16:37:26 -0700
Newsgroups gmane.comp.python.twisted
Message-ID <[email protected]>
On Mon, Jun 24, 2019, at 16:27, Chengi Liu wrote:
>  cpu_res *= yield *defer.*gatherResults*(cpus)

Remember: This will not block the reactor (Good!) but will still limit you to one CPU core (in general, some caveats, but true.) If you are CPU bound, this is woefully underutilizing modern CPU resources (again, some caveats here).

> if __name__ == '__main__':

In general, the best thing to do is to to use twisted.internet.task.react for main. This would also solve the other problem you point out below.

https://twistedmatrix.com/documents/current/api/twisted.internet.task.html#react has a good example.

_______________________________________________
Twisted-Python mailing list
[email protected]
https://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python