Permalink
Browse files

Refactor code for invoking plugins from map().

Create a method _invoke_one_plugin() to call the plugin and
append the results to a list to be returned.

Signed-off-by: Doug Hellmann <doug.hellmann@dreamhost.com>
  • Loading branch information...
1 parent 60c88f6 commit 79bd21f43df752fcdbff10ff40e8b1f78bb592b8 @dhellmann dhellmann committed Aug 21, 2012
Showing with 11 additions and 8 deletions.
  1. +11 −8 stevedore/extension.py
View
@@ -100,15 +100,18 @@ def func(ext, *args, **kwds):
raise RuntimeError('No %s extensions found' % self.namespace)
response = []
for e in self.extensions:
- try:
- response.append(func(e, *args, **kwds))
- except Exception as err:
- # FIXME: Provide an argument to control
- # whether to ignore exceptions in each
- # plugin or stop processing.
- LOG.error('error calling %r: %s', e.name, err)
- LOG.exception(err)
+ self._invoke_one_plugin(response, func, e, args, kwds)
return response
+ def _invoke_one_plugin(self, response, func, e, args, kwds):
+ try:
+ response.append(func(e, *args, **kwds))
+ except Exception as err:
+ # FIXME: Provide an argument to control
+ # whether to ignore exceptions in each
+ # plugin or stop processing.
+ LOG.error('error calling %r: %s', e.name, err)
+ LOG.exception(err)
+
def __iter__(self):
return iter(self.extensions)

0 comments on commit 79bd21f

Please sign in to comment.