# 需要导入模块: import queue [as 别名]
# 或者: from queue import task_done [as 别名]
def request_task(self, queue, setup_or_state_change_or_validation, test_functions, test_iteration):
try:
# Table data does not provide ability to inject unique agent_id's for each concurrent instance.
# The queue stores unique agent_id objects, injected by the new_thread function.
# Get the agent_id from the Queue and modify the original table data to change the agent_id to something unique.
http_request_body_tag = test_functions.get("http_request_body")
http_request_body_file_tag = test_functions.get("http_request_body_file")
if http_request_body_tag != None and http_request_body_file_tag != None :
self.fail("Test " + self._testMethodName + ":" + test_functions["function_name"] + " contains both http_request_body and http_request_body_file tags." )
thedata = ''
if http_request_body_tag == None and http_request_body_file_tag != None:
thedata = open(http_request_body_file_tag).read()
else:
thedata=http_request_body_tag
the_uid = queue.get()
jsondata = json.loads(thedata)
jsondata['agent_id'] = the_uid
newdata = json.dumps(jsondata)
# call the inline task passing the new data with the unique agent_id
self.execute_the_test(setup_or_state_change_or_validation, test_functions, test_iteration )
except Exception as e:
self.fail("Test " + self._testMethodName + ":" + test_functions["function_name"] + ", unexpected exception error: %s"%e )
finally:
queue.task_done()