I am trying to do some shared locking using with statements
def someMethod(self, hasLock = False):
with self.my_lock:
self.somethingElse(hasLock=True)
def somethingElse(self, hasLock = False):
#I want this to be conditional...
with self.my_lock:
print 'i hate hello worlds"
That make sense? I basically only want to do the with if I don't already have the lock.
On top of being able to accomplish this, is it a bad design? Should I just acquire/release myself?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…