python done_Python queue.task_done方法代码示例

# 需要导入模块: 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()

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值