zoukankan      html  css  js  c++  java
  • Python:多线程发起请求

    请求函数

    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
    每天努力一点,每天学习一点。 Keep Moving...
  • 相关阅读:
    分苹果
    马拉车算法(求最长回文子串)
    KMP
    字典树
    关于子类和父类中的this的用法
    最长上生子序列LIS
    sass
    黑马程序员----java基础笔记下(毕向东)
    DOM
    ajax教程
  • 原文地址:https://www.cnblogs.com/channy14/p/14737928.html
Copyright © 2011-2022 走看看