Merge lp:~stefanor/ibid/handle-plugin-setup-failure-726022 into lp:ibid

Proposed by Stefano Rivera
Status: Merged
Approved by: Stefano Rivera
Approved revision: 1047
Merged at revision: 1050
Proposed branch: lp:~stefanor/ibid/handle-plugin-setup-failure-726022
Merge into: lp:ibid
Diff against target: 47 lines (+21/-15)
1 file modified
ibid/core.py (+21/-15)
To merge this branch: bzr merge lp:~stefanor/ibid/handle-plugin-setup-failure-726022
Reviewer Review Type Date Requested Status
Jonathan Hitchcock Approve
Review via email: mp+116386@code.launchpad.net

Commit message

Catch Exceptions during Processor instantiation, rather than aborting an entire plugin load ecause of an exception

Description of the change

A single Processor that won't load shouldn't make a plugin unloadable.

To post a comment you must log in.
Revision history for this message
Jonathan Hitchcock (vhata) wrote :

:+1:

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'ibid/core.py'
--- ibid/core.py 2011-02-27 11:03:47 +0000
+++ ibid/core.py 2012-07-23 22:42:26 +0000
@@ -235,23 +235,29 @@
235 self.log.exception(u"Couldn't load %s plugin", name)235 self.log.exception(u"Couldn't load %s plugin", name)
236 return False236 return False
237237
238 try:238 for classname, klass in inspect.getmembers(m, inspect.isclass):
239 for classname, klass in inspect.getmembers(m, inspect.isclass):239 if (issubclass(klass, ibid.plugins.Processor)
240 if issubclass(klass, ibid.plugins.Processor) and klass != ibid.plugins.Processor:240 and klass != ibid.plugins.Processor):
241 if (klass.__name__ not in noload and (klass.__name__ in load241 if (klass.__name__ not in noload and (klass.__name__ in load
242 or ((load_all or klass.autoload) and not noload_all))):242 or ((load_all or klass.autoload) and not noload_all))):
243 self.log.debug("Loading Processor: %s.%s", name, klass.__name__)243 self.log.debug("Loading Processor: %s.%s", name,
244 klass.__name__)
245 try:
244 ibid.processors.append(klass(name))246 ibid.processors.append(klass(name))
245 else:247 except Exception, e:
246 self.log.debug("Skipping Processor: %s.%s", name, klass.__name__)248 self.log.exception(u"Couldn't instantiate %s "
249 u"processor of %s plugin",
250 classname, name)
251 continue
252 else:
253 self.log.debug("Skipping Processor: %s.%s", name,
254 klass.__name__)
247255
248 try:256 try:
249 schema_version_check(ibid.databases['ibid'])257 schema_version_check(ibid.databases['ibid'])
250 except SchemaVersionException, e:258 except SchemaVersionException, e:
251 self.log.error(u'Tables out of date: %s. Run "ibid-db --upgrade"', e.message)259 self.log.error(u'Tables out of date: %s. Run "ibid-db --upgrade"',
252 except Exception, e:260 e.message)
253 self.log.exception(u"Couldn't instantiate %s processor of %s plugin", classname, name)
254 return False
255261
256 ibid.processors.sort(key=lambda x: x.priority)262 ibid.processors.sort(key=lambda x: x.priority)
257263

Subscribers

People subscribed via source and target branches

to all changes: