Recommended number of threads? (in CPython)
Aahz
aahz at pythoncraft.com
Mon Nov 2 16:21:58 EST 2009
In article <mailman.2256.1256831821.2807.python-list at python.org>,
mk <mrkafk at gmail.com> wrote:
>
>I wrote run-of-the-mill program for concurrent execution of ssh command
>over a large number of hosts. (someone may ask why reinvent the wheel
>when there's pssh and shmux around -- I'm not happy with working details
>and lack of some options in either program)
>
>The program has a working queue of threads so that no more than
>maxthreads number are created and working at particular time.
>
>But this begs the question: what is the recommended number of threads
>working concurrently? If it's dependent on task, the task is: open ssh
>connection, execute command (then the main thread loops over the queue
>and if the thread is finished, it closes ssh connection and does .join()
>on the thread)
Given that you code is not just I/O-bound but wait-bound, I suggest
following the suggestion to use asynch code -- then you could open a
connection to every single machine simultaneously. Assuming your system
setup can handle the load, that is.
--
Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/
[on old computer technologies and programmers] "Fancy tail fins on a
brand new '59 Cadillac didn't mean throwing out a whole generation of
mechanics who started with model As." --Andrew Dalke
More information about the Python-list
mailing list