[Chris Withers]
> Anyone know what the difference is between Zope's ThreadLock module
> and the standard python Lock objects from the threading module?

A ThreadLock.ThreadLock is reentrant but a threading.Lock isn't:  once a
thread has acquired a ThreadLock, that thread can acquire that ThreadLock
again, any number of times, without blocking.  This is useful, e.g., for a
lock that wants to give a thread exclusive access to an object's methods,
where some of the methods may invoke other methods of the object.

That isn't true of a threading.Lock:  each attempt to acquire an
already-acquired Lock blocks until the Lock is released, regardless of which
thread may be trying to acquire.

The other difference is that an acquired ThreadLock can be released only by
the thread that acquired it, while any thread can release an acquired
threading.Lock.

A threading.RLock (note the "R") has the same semantics as a
ThreadLock.ThreadLock, though.  Zope's ThreadLock.c predates Python's
threading.py, and Python didn't offer any form of reentrant lock before
threading.py (although you could build your own on top of Python's thread
module's lock, which is in fact how threading.RLock and
ThreadLock.ThreadLock are implemented).


_______________________________________________
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope )

Reply via email to