scripts/rpc: Don't load same plugin module more than once
This is only relevant when rpc.py is running in server mode. Recent changes in argparse under python3.11 force it to raise the ArgumentError exception whenever subparser of the same name is being added. With that in mind, avoid extra call to spdk_rpc_plugin_initialize() by keeping track of all plugins that were already successfully initialized. Signed-off-by: Michal Berger <michal.berger@intel.com> Change-Id: I89124738b995ba774b6619f97726a5bd69fe1fd9 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15807 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Kamil Godzwon <kamilx.godzwon@intel.com> Reviewed-by: Pawel Piatek <pawelx.piatek@intel.com> Reviewed-by: Konrad Sztyber <konrad.sztyber@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Community-CI: Mellanox Build Bot
This commit is contained in:
parent
56f5f7e9d4
commit
5dcb6e2426
@ -3249,11 +3249,15 @@ Format: 'user:u1 secret:s1 muser:mu1 msecret:ms1,user:u2 secret:s2 muser:mu2 mse
|
||||
if args is not None:
|
||||
rpc_module = plugin_parser.parse_known_args(args)[0].rpc_plugin
|
||||
|
||||
if rpc_module in plugins:
|
||||
return
|
||||
|
||||
if rpc_module is not None:
|
||||
try:
|
||||
rpc_plugin = importlib.import_module(rpc_module)
|
||||
try:
|
||||
rpc_plugin.spdk_rpc_plugin_initialize(subparsers)
|
||||
plugins.append(rpc_module)
|
||||
except AttributeError:
|
||||
print("Module %s does not contain 'spdk_rpc_plugin_initialize' function" % rpc_module)
|
||||
except ModuleNotFoundError:
|
||||
@ -3269,6 +3273,7 @@ Format: 'user:u1 secret:s1 muser:mu1 msecret:ms1,user:u2 secret:s2 muser:mu2 mse
|
||||
if arg.startswith('--') and "_" in arg:
|
||||
args[i] = arg.replace('_', '-')
|
||||
|
||||
plugins = []
|
||||
load_plugin(None)
|
||||
|
||||
replace_arg_underscores(sys.argv)
|
||||
|
Loading…
Reference in New Issue
Block a user