I am trying to do some shared locking using with statements
def someMethod(self, hasLock = False): with self.my_lock: self.somethingElse(hasLoc
The with statement is a great way to implement locking, as locking is a perfect resource acquisition pattern. Though your current example won't work. You'll need an if statement around the with statement within somethingElse().
with
if
somethingElse()