def _log_results(self, results, log=None): if log is None: return for obj, exc in results: if exc is None: continue log('failed to close {!r} ({!r})'.format(obj, exc))