Locking error (?!?)

Scott Pigman scottpig at some.where.com
Fri Mar 28 16:31:55 CET 2003


is this a bug in my code or my brain:

------------------------------------- class Agent:

        assert self.lock.locked()

        assert self.lock.locked()

        response = self.OUT_SOCKET.recv(Agent.MESSAGE_BUFFER_SIZE) assert
        self.lock.locked()  ## FAILS

self.lock is an object of type threading.Lock, which was previously
acquired ( lock.acquire() ).  The first two assertions pass, the third one
fails.  can anybody give me some insight why?  I had thought that once
aquired, the lock will remain lock until the locking thread releases it. 
if not, then how do i get that behaviour?

thank's in advance,

Scott Pigman

More information about the Python-list mailing list