which threading libraries to use?

Chris Angelico rosuav at gmail.com
Sun Jun 12 01:01:53 EDT 2011


On Sun, Jun 12, 2011 at 2:10 PM, Dennis <daodennis at gmail.com> wrote:
> Hi,
>
> Are there any reasons besides personal preference to use one
> particular threading library over the other?  Eventlet, Twisted, and
> Python's native Threading class, or are there even others?  Are there
> any licensing or redistribution restrictions that I should be worried
> about?  Which ones do you consider best documented?  Most thread-safe?
> Efficient?

I use the native Threading class, myself, largely because it's so easy
to switch to multiprocessing if the GIL starts to get in the way. YMMV
if you don't use CPython.

> Ultimately this will be used for asynchronous SNMP, HTTP, and WMI.  I
> don't think this will need to evolve into a multi-process project,
> unless of course that is much easier to do than multi-threading?

In all probability, your threads will spend 99% of their time waiting
for the network. This makes threads very effective, and largely
eliminates the GIL issues (if they occasionally have to take turns,
it's not going to affect things much). Pick whichever threading
library suits your coding style; they'll all work, most likely.

Chris Angelico



More information about the Python-list mailing list