Skip to content

Commit

Permalink
Prevent exceptions raised in finally:
Browse files Browse the repository at this point in the history
closes #2136
  • Loading branch information
jortel committed Dec 15, 2016
1 parent 3c39a9f commit 68392c5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 15 deletions.
10 changes: 8 additions & 2 deletions server/pulp/plugins/util/publish_step.py
Expand Up @@ -162,7 +162,10 @@ def process_lifecycle(self):
for step in _post_order(self):
step.process()
finally:
self.report_progress(force=True)
try:
self.report_progress(force=True)
except Exception:
_logger.exception(_('Progress reporting failed'))

def is_skipped(self):
"""
Expand Down Expand Up @@ -257,7 +260,10 @@ def process(self):
return
finally:
# Always call finalize to allow cleanup of file handles
self.finalize()
try:
self.finalize()
except Exception:
_logger.exception(_('Finalizing failed'))
self.post_process()
except Exception as e:
tb = sys.exc_info()[2]
Expand Down
13 changes: 0 additions & 13 deletions server/test/unit/plugins/util/test_publish_step.py
Expand Up @@ -301,19 +301,6 @@ def test_get_conduit_not_set(self):
step = publish_step.PluginStep('foo_step')
self.assertEquals(None, step.get_conduit())

@patch('pulp.plugins.conduits.repo_publish.RepoPublishConduit.get_units')
def test_process_step_failure_reported_on_metadata_finalized(self, mock_get_units):
self.pluginstep.repo.content_unit_counts = {'FOO_TYPE': 1}
mock_get_units.return_value = ['mock_unit']
step = publish_step.PluginStep('foo_step')
step.parent = self.pluginstep
step.finalize = Mock(side_effect=Exception())
self.assertRaises(Exception, step.process)
self.assertEquals(step.state, reporting_constants.STATE_FAILED)
self.assertEquals(step.progress_successes, 1)
self.assertEquals(step.progress_failures, 1)
self.assertEquals(step.total_units, 1)

def test_cancel_before_processing(self):
self.pluginstep.repo.content_unit_counts = {'FOO_TYPE': 2}
step = publish_step.PluginStep('foo_step')
Expand Down

0 comments on commit 68392c5

Please sign in to comment.