

def _run_cleanups(self, cleanups):
    for (function, args, kwargs) in reversed(cleanups):
        try:
            function(*args, **kwargs)
        except Exception:
            if inspect.ismethod(function):
                if six.PY2:
                    cmodule = function.im_class.__module__
                    cname = function.im_class.__name__
                else:
                    cmodule = function.__self__.__class__.__module__
                    cname = function.__self__.__class__.__name__
                name = ('%s.%s.%s' % (cmodule, cname, function.__name__))
            elif inspect.isfunction(function):
                name = ('%s.%s' % (function.__module__, function.__name__))
            else:
                name = ('%s.%s' % (function.__class__.__module__, function.__class__.__name__))
            formatted_args = ''
            args_string = ', '.join([repr(arg) for arg in args])
            kwargs_string = ', '.join([('%s=%r' % (key, value)) for (key, value) in kwargs.items()])
            if args_string:
                formatted_args = args_string
            if kwargs_string:
                if formatted_args:
                    formatted_args += ', '
                formatted_args += kwargs_string
            LOG.warning((_LW('Error cleaning up %(name)s(%(args)s)') % {
                'name': name,
                'args': formatted_args,
            }), exc_info=True)
            pass

dataset/ETHPy150Open openstack/ec2-api/ec2api/api/common.py OnCrashCleaner._run_cleanups/original