Method objects and locking

Aaron Bentley aaron.bentley at utoronto.ca
Mon Nov 28 03:39:05 GMT 2005


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Robert Collins wrote:
| I noticed in a recent patch the following idiom with a MethodObject
| pattern:
|
|
| class MethodObject:
|     def __init__(self, branch):
|         self.branch = branch
|         self.something = self.branch.get_something()
|
|     def doTheThing(self):
|         self.branch.lock_read()
|         ...

The actual code Robert's referring to is bzrlib.check.Check, where
Branch._get_inventory_weave is called in the constructor.  I'm not sure
why I did that, but he's absolutely right about the race condition.

Aaron
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFDinvZ0F+nu1YWqI0RAv0ZAJ9albejA22S919BWKYbN6YBi0xJNACfQy1U
eEsLkFwksJnWpHViTorp+K0=
=kHCD
-----END PGP SIGNATURE-----




More information about the bazaar mailing list