diff options
author | Michael S. Pedersen <michael.soelvkaer@gmail.com> | 2019-12-03 11:38:32 +0000 |
---|---|---|
committer | Michael S. Pedersen <michael.soelvkaer@gmail.com> | 2019-12-09 22:07:08 +0000 |
commit | 95f2491ed89ac99b0d8bd006b4a13cbeb1eb96ce (patch) | |
tree | 8d2d8cd00f3284036e9bf78d9ec9bfdb3e95c80b /nfvbench/nfvbenchd.py | |
parent | 24314713446b6411cedce4329ab5ebfd6da678a2 (diff) |
NFVBENCH-153 Add support for python34.0.0
JIRA: NFVBENCH-153
Done using 2to3-3.6 with additional changes to fix data parsing and
testing (tox)
Signed-off-by: Michael S. Pedersen <michael.soelvkaer@gmail.com>
Change-Id: I242902f800da543d780507828c9bd1fbf409da6d
Diffstat (limited to 'nfvbench/nfvbenchd.py')
-rw-r--r-- | nfvbench/nfvbenchd.py | 51 |
1 files changed, 24 insertions, 27 deletions
diff --git a/nfvbench/nfvbenchd.py b/nfvbench/nfvbenchd.py index ae89e7a..73e1342 100644 --- a/nfvbench/nfvbenchd.py +++ b/nfvbench/nfvbenchd.py @@ -15,7 +15,7 @@ # import json -import Queue +import queue from threading import Thread import uuid @@ -23,13 +23,13 @@ from flask import Flask from flask import jsonify from flask import request -from summarizer import NFVBenchSummarizer +from .summarizer import NFVBenchSummarizer -from log import LOG -from utils import byteify -from utils import RunLock +from .log import LOG +from .utils import byteify +from .utils import RunLock -from __init__ import __version__ +from .__init__ import __version__ STATUS_OK = 'OK' STATUS_ERROR = 'ERROR' @@ -57,7 +57,7 @@ def get_uuid(): class Ctx(object): MAXLEN = 5 - run_queue = Queue.Queue() + run_queue = queue.Queue() busy = False result = None results = {} @@ -101,16 +101,15 @@ class Ctx(object): res = Ctx.results[request_id] except KeyError: return None - + # pylint: disable=unsubscriptable-object if Ctx.result and request_id == Ctx.result['request_id']: Ctx.result = None - - return res - else: - res = Ctx.result - if res: - Ctx.result = None return res + # pylint: enable=unsubscriptable-object + res = Ctx.result + if res: + Ctx.result = None + return res @staticmethod def is_busy(): @@ -159,20 +158,18 @@ def setup_flask(): return jsonify(res) # result for given request_id not found return jsonify(result_json(STATUS_NOT_FOUND, not_found_msg, request_id)) - else: - if Ctx.is_busy(): - # task still pending, return with request_id - return jsonify(result_json(STATUS_PENDING, - pending_msg, - Ctx.get_current_request_id())) - - res = Ctx.get_result() - if res: - return jsonify(res) - return jsonify(not_busy_json) + if Ctx.is_busy(): + # task still pending, return with request_id + return jsonify(result_json(STATUS_PENDING, + pending_msg, + Ctx.get_current_request_id())) - return app + res = Ctx.get_result() + if res: + return jsonify(res) + return jsonify(not_busy_json) + return app class WebServer(object): """This class takes care of the web server. Caller should simply create an instance @@ -200,7 +197,7 @@ class WebServer(object): # 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} + config = {k: v for k, v in list(config.items()) if v is not None} with RunLock(): if self.fluent_logger: self.fluent_logger.start_new_run() |