threads and sleep?
Grant Edwards
grante at visi.com
Tue Jul 5 11:48:41 EDT 2005
On 2005-07-05, Jeffrey Maitland <jeff.maitland at gmail.com> wrote:
> Ok here goes. The problem I have is I had an application
> (wrote/co-wrote) that has a long run time dependant on some variables
> passed to it (mainly accuracy variables, the more accurate the longer
> the run time - makes sense). However in the hopes to speed it up I
> decided to write a threaded version of the program to try and speed
> it up. How ever what I am noticing is that the threaded version is
> taking as long possibly longer to run. The thing is the threaded
> version is running on an 8 ia-64 proccessor system and it seems to
> only be using 2 or 3 porcessors at about 30% (fluxiates). My guess is
> that 6 threads are running they are using 30% sprox each of a 2 given
> CPUS.
Because of the global interpreter lock, a multi-threaded python
program does not take advantage of multiple processors. No
matter how many CPUs you have, only one thread is allowed to
run at any point in time.
Multi-threading in Python is useful for simplifying the
architecture of a program that has to do multiple independent
tasks, but it isn't useful for actually running multiple
threads in parallel.
--
Grant Edwards grante Yow! Inside, I'm already
at SOBBING!
visi.com
More information about the Python-list
mailing list