[Python-Dev] Pre-PEP: with syntax (was: New syntax threads -- summary wanted) (original) (raw)

Aahz aahz@pythoncraft.com
Mon, 10 Feb 2003 10:29:52 -0500


On Mon, Feb 10, 2003, Bernhard Herzog wrote:

In the particular case of locks, the threading.Lock object's release method must only be called when it's locked (same for the other lock objects AFAICT). Seems to me that this would require a flag at the python level and then you have the race condition.

That's not a problem for threading.RLock(). You can code that as

lock = threading.RLock()
try:
    lock.acquire()
finally:
    lock.release()

Note that currently there's an AssertionError in threading when you do that; perhaps that should be changed to a Warning?

Aahz (aahz@pythoncraft.com) <*> http://www.pythoncraft.com/

Register for PyCon now! http://www.python.org/pycon/reg.html