Cliff Wells clifford.wells at comcast.net
Wed Oct 13 13:18:14 CEST 2004

On Wed, 2004-10-13 at 21:05 +1000, Ajay wrote:
> hi!
> what would happen if i try to access a variable locked by another thread? i
> am not trying to obtain a lock on it, just trying to access it.

First of all, why not just try it and see?  Secondly, nothing will
prevent you from accessing it.  Locks in Python are advisory only.  Just
be aware that locks typically exist for a reason.  Just because you
aren't modifying the variable doesn't mean you won't shoot yourself in
the foot.  If the variable is mutable (such as a list or dictionary),
then you risk seeing a partially updated variable if the other thread is
in the midst of updating it.  This may be acceptable for your
application or it may not.


Cliff Wells <clifford.wells at comcast.net>

More information about the Python-list mailing list