Repository.item_keys_introduced_by should not lock Repository
John Arbash Meinel
john at arbash-meinel.com
Thu Oct 18 23:56:24 BST 2007
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
I just noticed that inside Repository.item_keys_introduced_by we have a
'self.lock_read()' call and a 'self.unlock()' call.
This really isn't a good thing, and is one of the reasons we see the "Failed to
unlock" errors when an operation is canceled by the user.
The problem is that you can't use a try/finally in a generator (because the
generator is not guaranteed to finish.)
So instead, the api should be that it does something like:
if not self.is_locked():
raise errors.ObjectNotLocked(self)
And then the caller is charged with having a lock for the appropriate length of
time.
I don't know if this happens elsewhere, but in general all of our generators
should not be taking locks.
(I know we had a funny interaction with @needs_read_lock decorators. Which
effectively meant they were locked for the initial call, but unlocked for the
whole iteration time.)
Certainly this should be the sort of thing caught in a review. I'm not sure how
we missed it.
John
=:->
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFHF+SYJdeBCYSNAAMRAh+QAKDX7KavJgmWpYANkod8Gc5AqzFgfwCaA1Gm
c2N/wJP5iTMx1nZrHi5lyqQ=
=jRNU
-----END PGP SIGNATURE-----
More information about the bazaar
mailing list