[Python-Dev] Threading idea -- exposing a global thread lock (original) (raw)

"Martin v. Löwis" martin at v.loewis.de
Tue Mar 14 22:17:10 CET 2006


Raymond Hettinger wrote:

Once place where we already have CPython specific support is in sys.setcheckinterval(). That suggests adapting that function or adding a new one to temporarily stop switching, almost the same as sys.setcheckinterval(sys.maxint) but continuing to perform other periodic checks for control-break and such.

I object to the notion that Python does "thread switching". It doesn't. Instead, it releases the GIL under certain circumstances, which might make the operating system switch threads. Whether the operating system does that is its own choice.

I don't see a value to disabling the "release the GIL from time to time". This does not mean there couldn't be thread-switching, anymore. E.g. inside a PRINT_* opcode, thread-switching may still occur, as file_write releases the GIL around the fwrite() call. So if you set the checkinterval to "no check", you cannot trust that there won't be any thread switching.

Regards, Martin



More information about the Python-Dev mailing list