[Python-Dev] Reworking the GIL (original) (raw)
Antoine Pitrou solipsis at pitrou.net
Mon Oct 26 11:19:00 CET 2009
- Previous message: [Python-Dev] Reworking the GIL
- Next message: [Python-Dev] Reworking the GIL
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Terry Reedy <tjreedy udel.edu> writes:
I am curious as to whether the entire mechanism is or can be turned off when not needed -- when there are not threads (other than the main, starting thread)?
It is an implicit feature: when no thread is waiting on the GIL, the GIL-holding thread isn't notified and doesn't try to release it at all (in the eval loop, that is; GIL-releasing C extensions still release it).
Note that "no thread is waiting on the GIL" can mean one of two things:
- either there is only one Python thread
- or the other Python threads are doing things with the GIL released (zlib/bz2 compression, waiting on I/O, sleep()ing, etc.)
So, yes, it automatically "turns itself off".
Regards
Antoine.
- Previous message: [Python-Dev] Reworking the GIL
- Next message: [Python-Dev] Reworking the GIL
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]