summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorchenjiankun <chenjiankun1@huawei.com>2016-11-25 02:57:50 +0000
committerchenjiankun <chenjiankun1@huawei.com>2016-11-25 02:59:55 +0000
commite5b312fc2d09346c75be9e0df2aa9eb20ee4529f (patch)
tree10ee9bcfb27cd966b01af93d7afbfc2e3df2cf23
parent450c047a8812d3d9e772f26a2faeb17acef3e90a (diff)
ArgsAlreadyParsedError: arguments already parsed: cannot register CLI option
JIRA: YARDSTICK-216 When I call YardstickCLI in flask, it will always encounter a ArgsAlreadyParsedError if the API run test case more than two times. In YardstickCLI, if I just call CONF.clear(), it will occur another error due to other opts not unregister. I don’t know if the problem is on the oslo.config side. I solve the problem by unregister the opts. Change-Id: Ic898c8d62625785ceb793c75e8210ac354ac63bf Signed-off-by: chenjiankun <chenjiankun1@huawei.com>
-rw-r--r--yardstick/cmd/cli.py17
1 files changed, 16 insertions, 1 deletions
diff --git a/yardstick/cmd/cli.py b/yardstick/cmd/cli.py
index 3896ce47c..ee8d1c529 100644
--- a/yardstick/cmd/cli.py
+++ b/yardstick/cmd/cli.py
@@ -66,6 +66,7 @@ class YardstickCLI():
}
def __init__(self):
+ self.opts = []
self._version = 'yardstick version %s ' % \
get_distribution('yardstick').version
@@ -111,7 +112,12 @@ class YardstickCLI():
title="Command categories",
help="Available categories",
handler=parser)
- CONF.register_cli_opt(category_opt)
+ self._register_opt(category_opt)
+
+ def _register_opt(self, opt):
+
+ CONF.register_cli_opt(opt)
+ self.opts.append(opt)
def _load_cli_config(self, argv):
@@ -143,6 +149,11 @@ class YardstickCLI():
func = CONF.category.func
func(CONF.category, task_id=task_id)
+ def _clear_config_opts(self):
+
+ CONF.clear()
+ CONF.unregister_opts(self.opts)
+
def main(self, argv): # pragma: no cover
'''run the command line interface'''
self._register_cli_opt()
@@ -153,6 +164,8 @@ class YardstickCLI():
self._dispath_func_notask()
+ self._clear_config_opts()
+
def api(self, argv, task_id): # pragma: no cover
'''run the api interface'''
self._register_cli_opt()
@@ -162,3 +175,5 @@ class YardstickCLI():
self._handle_global_opts()
self._dispath_func_task(task_id)
+
+ self._clear_config_opts()