From 42b8c6bee8e2f64c53b86ceba76210645b10da69 Mon Sep 17 00:00:00 2001 From: ahothan Date: Sat, 24 Mar 2018 17:09:36 -0700 Subject: [NFVBENCH-76] REST API remains in running state in case of exception catch the exception if result key is missing Change-Id: Id212497bb760b835b542afd11ffbe149bc3d46e7 Signed-off-by: ahothan --- nfvbench/nfvbenchd.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/nfvbench/nfvbenchd.py b/nfvbench/nfvbenchd.py index 76906c5..fa781af 100644 --- a/nfvbench/nfvbenchd.py +++ b/nfvbench/nfvbenchd.py @@ -226,7 +226,7 @@ class WebSocketIoServer(object): # print 'main thread waiting for requests...' config = Ctx.dequeue() # print 'main thread processing request...' - print config + # print config try: # remove unfilled values as we do not want them to override default values with None config = {k: v for k, v in config.items() if v is not None} @@ -243,8 +243,15 @@ class WebSocketIoServer(object): else: # this might overwrite a previously unfetched result Ctx.set_result(results) - summary = NFVBenchSummarizer(results['result'], self.fluent_logger) - LOG.info(str(summary)) + try: + summary = NFVBenchSummarizer(results['result'], self.fluent_logger) + LOG.info(str(summary)) + except KeyError: + # in case of error, 'result' might be missing + if 'error_message' in results: + LOG.error(results['error_message']) + else: + LOG.error('REST request completed without results or error message') Ctx.release() if self.fluent_logger: self.fluent_logger.send_run_summary(True) -- cgit 1.2.3-korg