Python でオブジェクトを「ロック」するにはどうすればよいですか?
私が持っているとしましょう:
class Foo:
def __init__(self):
self.bar = []
self.qnx = 10
必要なだけ foo を変更します。
foo = Foo()
foo.bar.append('blah')
foo.qnx = 20
しかし、それを「ロック」できるようにしたいのですが、試してみると
lock(foo)
foo.bar.append('blah') # raises some exception.
foo.qnx = 20 # raises some exception.
それはPythonで可能ですか?