Skip to content

Commit

Permalink
Fixed bug when sending signal
Browse files Browse the repository at this point in the history
  • Loading branch information
guiqiqi committed Jan 25, 2022
1 parent 5312b24 commit d8c0e64
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions src/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ def scan(self) -> t.Iterable[Plugin]:
# Check if plugin module contains ``plugin`` variable
if not hasattr(module, 'plugin'):
raise ImportError('module does not have plugin instance.')
except (ImportError, FileNotFoundError) as error:
except Exception as error:
if self._app.propagate_exceptions:
raise
self._app.logger.warn(
Expand Down Expand Up @@ -280,7 +280,7 @@ def load(self, plugin: Plugin) -> None:
plugin.load(self._app, self._config)
self._loaded[plugin] = plugin.basedir
self._app.logger.info(f'loaded plugin: {plugin.name}')
signals.loaded.send(self, plugin)
signals.loaded.send(self, plugin=plugin)

def start(self, plugin: Plugin) -> None:
"""
Expand All @@ -292,7 +292,7 @@ def start(self, plugin: Plugin) -> None:
plugin.status.assert_allow('start')
plugin.register(self._app, self._config)
self._app.logger.info(f'started plugin: {plugin.name}')
signals.started.send(self, plugin)
signals.started.send(self, plugin=plugin)

def stop(self, plugin: Plugin) -> None:
"""
Expand All @@ -304,7 +304,7 @@ def stop(self, plugin: Plugin) -> None:
plugin.status.assert_allow('stop')
plugin.unregister(self._app, self._config)
self._app.logger.info(f'stopped plugin: {plugin.name}')
signals.stopped.send(self, plugin)
signals.stopped.send(self, plugin=plugin)

def unload(self, plugin: Plugin) -> None:
"""
Expand All @@ -317,4 +317,4 @@ def unload(self, plugin: Plugin) -> None:
plugin.clean(self._app, self._config)
self._loaded.pop(plugin)
self._app.logger.info(f'unloaded plugin: {plugin.name}')
signals.unloaded.send(self, plugin)
signals.unloaded.send(self, plugin=plugin)
2 changes: 1 addition & 1 deletion src/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Contains all custom signals based on ``flask.signals.Namespace``.
All these signals send with caller as instance of :py:class:`.PluginManager`,
and the only argument is plugin instance operated.
and the only argument named `plugin` is plugin instance operated.
If you want to receive these signals, please install the blinker library,
see: https://flask.palletsprojects.com/en/2.0.x/signals/
Expand Down

0 comments on commit d8c0e64

Please sign in to comment.