No output from threads

David Bolen db3l at fitlinxx.com
Thu Apr 4 16:13:04 EST 2002


Jeff Shannon <jeff at ccvcorp.com> writes:

> A word of warning, though -- you may not be getting much usage of 
> your second processor.  Python itself has a Global Interpreter 
> Lock, forcing only one Python thread to be running at any given 
> time.  Secondary threads are not run on multiple processors.  You 
> may not be having this problem, since you're executing external 
> programs -- I'd imagine that those could be scheduled on the 
> second processor, but you should verify this.

Actually, threads can certainly run on any of multiple processors,
since they should be scheduled by the OS, but they can't be
interpreting Python code simultaneously.  But that doesn't stop them
from executing on different processors when they do get control of the
GIL.  Whether or not it will actually happen will depend on the
underlying OS SMP implementation, but shouldn't be limited (aside from
total CPU that can be spent interpreting code) by Python's GIL.

In this case, since external processes are being executed (it wasn't
mentioned but I assume through os.system(), os.popen() or some such
call), the GIL is going to be released before the OS-level execution
API call is made and execution by other threads on other processors
can continue.

So you'll still end up with at most one CPU's worth of time spent
interpreting Python code, but the external processes can use any
remaining CPU time.

--
-- David
-- 
/-----------------------------------------------------------------------\
 \               David Bolen            \   E-mail: db3l at fitlinxx.com  /
  |             FitLinxx, Inc.            \  Phone: (203) 708-5192    |
 /  860 Canal Street, Stamford, CT  06902   \  Fax: (203) 316-5150     \
\-----------------------------------------------------------------------/



More information about the Python-list mailing list