/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/lru_cache.py

  • Committer: John Arbash Meinel
  • Date: 2009-07-08 14:28:04 UTC
  • mto: This revision was merged to the branch mainline in revision 4521.
  • Revision ID: john@arbash-meinel.com-20090708142804-i9rkpi9dmnu7v3x1
Fix bug #396838, Update LRUCache to maintain invariant even
if a cleanup function raises an exception.

Show diffs side-by-side

added added

removed removed

Lines of Context:
52
52
            if self.cleanup is not None:
53
53
                self.cleanup(self.key, self.value)
54
54
        finally:
55
 
            # cleanup might raise an exception, but we want to make sure
56
 
            # to break refcycles, etc
57
55
            self.cleanup = None
 
56
            # Just make sure to break any refcycles, etc
58
57
            self.value = None
59
58
 
60
59
 
162
161
            try:
163
162
                node.run_cleanup()
164
163
            finally:
165
 
                # Maintain the LRU properties, even if cleanup raises an
166
 
                # exception
167
164
                node.value = value
168
165
                node.cleanup = cleanup
169
166
                self._record_access(node)
252
249
        try:
253
250
            node.run_cleanup()
254
251
        finally:
255
 
            # cleanup might raise an exception, but we want to make sure to
256
 
            # maintain the linked list
 
252
            # Now remove this node from the linked list
257
253
            if node.prev is not None:
258
254
                node.prev.next_key = node.next_key
259
255
            if node.next_key is not _null_key: