global interpreter lock not working as it should
brueckd at tbye.com
brueckd at tbye.com
Thu Aug 1 14:15:28 EDT 2002
On 1 Aug 2002, Armin Steinhoff wrote:
> > Not all built-in functions that may block waiting for I/O allow other threads >to run. (The most popular ones (time.sleep(), file.read(),
> >select.select()) work as expected.)
>
> Yes ... only the most 'popular' ones are working
So which ones aren't working for you? Please post some code.
> (because there is only ONE
> system thread (or process) spent for the interpreter)
Really? Consider:
import threading, time
def f():
while 1:
time.sleep(1)
for i in range(3):
threading.Thread(target=f).start()
Now from my Linux cmd line:
> ps -aux | grep python
dave 16839 0.0 0.7 9272 1868 pts/4 S 11:07 0:00 python
dave 16840 0.0 0.7 9272 1868 pts/4 S 11:07 0:00 python
dave 16841 0.0 0.7 9272 1868 pts/4 S 11:07 0:00 python
dave 16842 0.0 0.7 9272 1868 pts/4 S 11:07 0:00 python
On Linux this is especially easy to see because you basically get one
process per thread, but on other platforms (e.g. Windows) C-level calls to
get the number of threads by the process return the correct number (at
least 4 in this case).
More information about the Python-list
mailing list