/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 breezy/cleanup.py

  • Committer: Jelmer Vernooij
  • Date: 2019-03-04 00:16:27 UTC
  • mfrom: (7293 work)
  • mto: This revision was merged to the branch mainline in revision 7318.
  • Revision ID: jelmer@jelmer.uk-20190304001627-v6u7o6pf97tukhek
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
44
44
from __future__ import absolute_import
45
45
 
46
46
from collections import deque
47
 
import sys
48
47
from . import (
49
48
    debug,
50
49
    trace,
51
50
    )
52
51
 
 
52
 
53
53
def _log_cleanup_error(exc):
54
54
    trace.mutter('Cleanup failed:')
55
55
    trace.log_exception_quietly()
84
84
 
85
85
    Subclass or client code can call add_cleanup and then later `cleanup_now`.
86
86
    """
 
87
 
87
88
    def __init__(self):
88
89
        self.cleanups = deque()
89
90
 
90
91
    def add_cleanup(self, cleanup_func, *args, **kwargs):
91
92
        """Add a cleanup to run.
92
93
 
93
 
        Cleanups may be added at any time.  
 
94
        Cleanups may be added at any time.
94
95
        Cleanups will be executed in LIFO order.
95
96
        """
96
97
        self.cleanups.appendleft((cleanup_func, args, kwargs))
163
164
    """
164
165
    try:
165
166
        result = func(*args, **kwargs)
166
 
    except:
 
167
    except BaseException:
167
168
        # We have an exception from func already, so suppress cleanup errors.
168
169
        _run_cleanups(cleanup_funcs)
169
170
        raise
172
173
    try:
173
174
        for cleanup, c_args, c_kwargs in pending_cleanups:
174
175
            cleanup(*c_args, **c_kwargs)
175
 
    except:
 
176
    except BaseException:
176
177
        # Still run the remaining cleanups but suppress any further errors.
177
178
        _run_cleanups(pending_cleanups)
178
179
        raise