channy14

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

请求函数

def s3_put_file(fileKey):
    print u'用例开始:'
    currentFile = test_currentFile_730kb
    # S3 PUT上传文件
    date = get_utctime()
    rq = s3FileOp('PUT', fileKey, test_ak,  test_sk, test_bucket, date, test_s3_url, currentFile)
    if rq.status_code != 200:
        print u'Error!',fileKey
View Code

 

并发请求:

    def test_call_thread_50_730kb_file(self):
        print u'用例开始:'
        current_time = getUnixTime()
        name_list =[]
        for i in range(3000000):
            name_list.append('s3_put_730k_' + str(i+100001))
        start_time = time.time()
        pool = threadpool.ThreadPool(50)
        requests = threadpool.makeRequests(s3_put_file, name_list) 
        [pool.putRequest(req) for req in requests] 
        pool.wait() 
        print '%d second'% (time.time()-start_time)
View Code

 

posted on 2021-05-07 10:03  channy14  阅读(638)  评论(0)    收藏  举报