Prevent the plugin from being initialized again within the lock scope if another thread had it initialized in the meantime
This commit is contained in:
parent
98d24b061a
commit
db5d3e6e3f
1 changed files with 5 additions and 3 deletions
|
@ -94,13 +94,15 @@ def get_plugin(plugin_name, reload=False):
|
|||
|
||||
try:
|
||||
plugin_class = getattr(plugin, cls_name)
|
||||
|
||||
with plugins_init_locks[plugin_name]:
|
||||
plugins[plugin_name] = plugin_class(**plugin_conf)
|
||||
except AttributeError as e:
|
||||
logger.warning('No such class in {}: {}'.format(plugin_name, cls_name))
|
||||
raise RuntimeError(e)
|
||||
|
||||
with plugins_init_locks[plugin_name]:
|
||||
if plugins.get(plugin_name) and not reload:
|
||||
return plugins[plugin_name]
|
||||
plugins[plugin_name] = plugin_class(**plugin_conf)
|
||||
|
||||
return plugins[plugin_name]
|
||||
|
||||
def get_bus():
|
||||
|
|
Loading…
Reference in a new issue