Skip to content

Add default init method for pylightning plugins#2271

Closed
conscott wants to merge 1 commit into
ElementsProject:masterfrom
conscott:default_plugin_init
Closed

Add default init method for pylightning plugins#2271
conscott wants to merge 1 commit into
ElementsProject:masterfrom
conscott:default_plugin_init

Conversation

@conscott
Copy link
Copy Markdown
Collaborator

When making python plugins, it should be okay to not implement an init method. Currently the plugin will crash if it is not supplied (it's the first thing lightningd calls), so this change adds a default that does nothing.

You can test by removing these lines from the helloworld.py plugin, and also note that the self._init method is still called regardless.

@conscott conscott requested a review from cdecker as a code owner January 16, 2019 16:12
@conscott conscott changed the title Add a default init method for pylightning plugins Add default init method for pylightning plugins Jan 16, 2019
@cdecker
Copy link
Copy Markdown
Member

cdecker commented Jan 16, 2019

Hopefully #2237 will be merged soon. It also contains the fix of de-indenting the self.init re-assignment, which also fixes this alone, without the need to add a default init method.

if 'init' in self.methods:
self.init = self.methods['init']
self.methods['init'] = self._init
self.methods['init'] = self._init
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is one of the patches in #2237 as well.

return None

# default init method does nothing
def init(self, options, configuration, plugin):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you keep the self.init = None line above this is not really required.

@conscott
Copy link
Copy Markdown
Collaborator Author

👍 sounds good, must have missed that before. I'll try to give #2271 another honest review

@conscott conscott closed this Jan 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants