[Python-Dev] Re: Atomic operations

Skip Montanaro skip@pobox.com
Mon, 10 Feb 2003 08:25:38 -0600


    Brett> I was actually thinking more along the lines of having something
    Brett> like::

    Brett>  atomic:
    Brett>      lock()
    Brett>  ...

    Brett> with atomic basically shutting down threading temporarily until
    Brett> everything in its body is executed.  

This would presumably generate bytecode something like:

    GRAB_GIL
    lock()
    ... execute the block's code ...
    unlock()
    RELEASE_GIL

Suppose code in your block makes a call to a threading-aware extension
module.  Won't it obligingly release the GIL if it goes to do some longish
operation?  If so, wouldn't you then be screwed?

Skip