[merge][#109520] gc of LockableFiles should not warn or unlock

Martin Pool mbp at canonical.com
Wed Mar 19 02:18:05 GMT 2008


  https://bugs.launchpad.net/bzr/+bug/109520
  https://bugs.launchpad.net/bzr/+bug/137387

The __del__ method of LockableFiles complains if the object was not
unlocked before being destroyed.  This may indicate a bug where we did
not match a finally/unlock with the lock, though it can also commonly
occur in other cases, such as losing the transport and therefore not
being able to unlock the files, or a failure in another finally block.

Ideally we would detect the static errors and turn them in to test
suite failures.  However, gc is a poor way to do this because it's
hard to map the failure back to the code that locked it, and the gc
may not happen until after the relevant test has finished.  I'm not
sure it's a big deal because it's relatively easy to detect in code
review that a finally block is needed.

I think it's poor to show it to users by default, since they cannot do
anything about it and probably rarely feel like reporting it, nor do
they have much information to report.

In the test suite to me it seems to clutter the output without
particularly helping debugging.

Having thought this through, I actually want to take this one step
further and remove the unlock call from the del method.  Leaving
something locked is not so bad, trying to unlock when we may be
disconnected from the server causes knock-on failures, and in general
we try to avoid doing anything substantial from del methods.

-- 
Martin <http://launchpad.net/~mbp/>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 20080319-lock-warnings.diff
Type: text/x-diff
Size: 3086 bytes
Desc: not available
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20080319/047194a1/attachment-0001.bin 


More information about the bazaar mailing list