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
1=== modified file 'ibid/core.py'
2--- ibid/core.py 2011-02-27 11:03:47 +0000
3+++ ibid/core.py 2012-07-23 22:42:26 +0000
4@@ -235,23 +235,29 @@
5 self.log.exception(u"Couldn't load %s plugin", name)
6 return False
7
8- try:
9- for classname, klass in inspect.getmembers(m, inspect.isclass):
10- if issubclass(klass, ibid.plugins.Processor) and klass != ibid.plugins.Processor:
11- if (klass.__name__ not in noload and (klass.__name__ in load
12- or ((load_all or klass.autoload) and not noload_all))):
13- self.log.debug("Loading Processor: %s.%s", name, klass.__name__)
14+ for classname, klass in inspect.getmembers(m, inspect.isclass):
15+ if (issubclass(klass, ibid.plugins.Processor)
16+ and klass != ibid.plugins.Processor):
17+ if (klass.__name__ not in noload and (klass.__name__ in load
18+ or ((load_all or klass.autoload) and not noload_all))):
19+ self.log.debug("Loading Processor: %s.%s", name,
20+ klass.__name__)
21+ try:
22 ibid.processors.append(klass(name))
23- else:
24- self.log.debug("Skipping Processor: %s.%s", name, klass.__name__)
25+ except Exception, e:
26+ self.log.exception(u"Couldn't instantiate %s "
27+ u"processor of %s plugin",
28+ classname, name)
29+ continue
30+ else:
31+ self.log.debug("Skipping Processor: %s.%s", name,
32+ klass.__name__)
33
34- try:
35- schema_version_check(ibid.databases['ibid'])
36- except SchemaVersionException, e:
37- self.log.error(u'Tables out of date: %s. Run "ibid-db --upgrade"', e.message)
38- except Exception, e:
39- self.log.exception(u"Couldn't instantiate %s processor of %s plugin", classname, name)
40- return False
41+ try:
42+ schema_version_check(ibid.databases['ibid'])
43+ except SchemaVersionException, e:
44+ self.log.error(u'Tables out of date: %s. Run "ibid-db --upgrade"',
45+ e.message)
46
47 ibid.processors.sort(key=lambda x: x.priority)
48

Subscribers

People subscribed via source and target branches

to all changes: