当前位置: 首页>>代码示例>>Python>>正文


Python Thread.run_number方法代码示例

本文整理汇总了Python中threading.Thread.run_number方法的典型用法代码示例。如果您正苦于以下问题:Python Thread.run_number方法的具体用法?Python Thread.run_number怎么用?Python Thread.run_number使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在threading.Thread的用法示例。


在下文中一共展示了Thread.run_number方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: download

# 需要导入模块: from threading import Thread [as 别名]
# 或者: from threading.Thread import run_number [as 别名]
 def download(self):
     total_downloaded = 0
     connections = [
         self.connect(self.host) for i in range(self.runs)
     ]
     total_start_time = time()
     for current_file in SpeedTest.DOWNLOAD_FILES:
         threads = []
         for run in range(self.runs):
             thread = Thread(
                 target=self.downloadthread,
                 args=(connections[run],
                       '%s?x=%d' % (current_file, int(time() * 1000))))
             thread.run_number = run + 1
             thread.start()
             threads.append(thread)
         for thread in threads:
             thread.join()
             total_downloaded += thread.downloaded
             LOG.debug('Run %d for %s finished',
                       thread.run_number, current_file)
     total_ms = (time() - total_start_time) * 1000
     for connection in connections:
         connection.close()
     LOG.info('Took %d ms to download %d bytes',
              total_ms, total_downloaded)
     return total_downloaded * 8000 / total_ms
开发者ID:fopina,项目名称:pyspeedtest,代码行数:29,代码来源:pyspeedtest.py

示例2: upload

# 需要导入模块: from threading import Thread [as 别名]
# 或者: from threading.Thread import run_number [as 别名]
    def upload(self):
        connections = [
            self.connect(self.host) for i in range(self.runs)
        ]

        post_data = [
            urlencode({'content0': content(s)}) for s in SpeedTest.UPLOAD_FILES
        ]

        total_uploaded = 0
        total_start_time = time()
        for data in post_data:
            threads = []
            for run in range(self.runs):
                thread = Thread(target=self.uploadthread,
                                args=(connections[run], data))
                thread.run_number = run + 1
                thread.start()
                threads.append(thread)
            for thread in threads:
                thread.join()
                LOG.debug('Run %d for %d bytes finished',
                          thread.run_number, thread.uploaded)
                total_uploaded += thread.uploaded
        total_ms = (time() - total_start_time) * 1000
        for connection in connections:
            connection.close()
        LOG.info('Took %d ms to upload %d bytes',
                 total_ms, total_uploaded)
        return total_uploaded * 8000 / total_ms
开发者ID:fopina,项目名称:pyspeedtest,代码行数:32,代码来源:pyspeedtest.py

示例3: download

# 需要导入模块: from threading import Thread [as 别名]
# 或者: from threading.Thread import run_number [as 别名]
 def download(self, urls=None):
     total_downloaded = 0
     if urls is None:
         connections = [self.connect(self.host) for i in range(self.runs)]
     else:
         connections = [self.connect(h['host']) for h in urls]
     total_start_time = time()
     for current_file in self.DOWNLOAD_FILES:
         threads = []
         for run in range(self.runs):
             thread = Thread(
                 target=self.downloadthread,
                 args=(connections[run],
                       '%s?x=%d' % (current_file, int(time() * 1000))
                       if urls is None else urls[run]['url']))
             thread.run_number = run + 1
             thread.start()
             threads.append(thread)
         for thread in threads:
             try:
                 thread.join()
                 total_downloaded += thread.downloaded
                 util.debug('[SC] Run %d for %s finished' %
                            (thread.run_number, current_file))
             except:
                 pass
     total_ms = (time() - total_start_time) * 1000
     for connection in connections:
         connection.close()
     util.info('[SC] Took %d ms to download %d bytes' % (total_ms,
                                                         total_downloaded))
     return total_downloaded * 8000 / total_ms
开发者ID:milokmet,项目名称:plugin.video.stream-cinema,代码行数:34,代码来源:speedtest.py

示例4: download

# 需要导入模块: from threading import Thread [as 别名]
# 或者: from threading.Thread import run_number [as 别名]
def download(exclude=[]):
    total_downloaded = 0
    connections = []
    for run in range(RUNS):
        connection = httplib.HTTPConnection(HOST)
        connection.set_debuglevel(HTTPDEBUG)
        connection.connect()
        connections.append(connection)
    total_start_time = time()
    for current_file in [x for x in DOWNLOAD_FILES if x not in exclude]:
        threads = []
        for run in range(RUNS):
            thread = Thread(target=downloadthread,
                            args=(connections[run], current_file))
            thread.run_number = run
            thread.start()
            threads.append(thread)
        for thread in threads:
            thread.join()
            total_downloaded += thread.downloaded
            printv('Run %d for %s finished' %
                   (thread.run_number, current_file))
    total_ms = (time() - total_start_time) * 1000
    for connection in connections:
        connection.close()
    printv('Took %d ms to download %d bytes' % (total_ms, total_downloaded))
    return (total_downloaded * 8000 / total_ms)
开发者ID:bearstech,项目名称:bokor,代码行数:29,代码来源:bwtest.py

示例5: upload

# 需要导入模块: from threading import Thread [as 别名]
# 或者: from threading.Thread import run_number [as 别名]
def upload():
    connections = []
    for run in range(RUNS):
        connection = httplib.HTTPConnection(HOST)
        connection.set_debuglevel(HTTPDEBUG)
        connection.connect()
        connections.append(connection)

    post_data = []
    ALPHABET = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
    for current_file_size in UPLOAD_FILES:
        values = {'content': ''.join(random.choice(ALPHABET)
                                     for i in range(current_file_size))}
        post_data.append(urllib.urlencode(values))

    total_uploaded = 0
    total_start_time = time()
    for data in post_data:
        threads = []
        for run in range(RUNS):
            thread = Thread(target=uploadthread, args=(connections[run], data))
            thread.run_number = run
            thread.start()
            threads.append(thread)
        for thread in threads:
            thread.join()
            printv('Run %d for %d bytes finished' %
                   (thread.run_number, thread.uploaded))
            total_uploaded += thread.uploaded
    total_ms = (time() - total_start_time) * 1000
    for connection in connections:
        connection.close()
    printv('Took %d ms to upload %d bytes' % (total_ms, total_uploaded))
    return (total_uploaded * 8000 / total_ms)
开发者ID:bearstech,项目名称:bokor,代码行数:36,代码来源:bwtest.py

示例6: upload

# 需要导入模块: from threading import Thread [as 别名]
# 或者: from threading.Thread import run_number [as 别名]
    def upload(self):
        """ Perform multiple uploads in threads."""
        connections = []
        for run in range(self.runs):
            connections.append(self.connect(self.host))

        post_data = []
        for current_file_size in SpeedTest.UPLOAD_FILES:
            values = {
                'content0': ''.join(
                    random.choice(SpeedTest.ALPHABET) for i in range(current_file_size))
            }
            post_data.append(urlencode(values))

        total_uploaded = 0
        total_start_time = time()
        for data in post_data:
            threads = []
            for run in range(self.runs):
                thread = Thread(target=self.uploadthread,
                                args=(connections[run], data))
                thread.run_number = run + 1
                thread.start()
                threads.append(thread)
            for thread in threads:
                thread.join()
                logging.info('Run %d for %d bytes finished',
                             thread.run_number, thread.uploaded)
                total_uploaded += thread.uploaded
        total_ms = (time() - total_start_time) * 1000
        for connection in connections:
            connection.close()
        logging.info('Took %d ms to upload %d bytes',
                     total_ms, total_uploaded)
        return total_uploaded * 8000 / total_ms
开发者ID:GadgetSteve,项目名称:pyspeedtest,代码行数:37,代码来源:pyspeedtest.py


注:本文中的threading.Thread.run_number方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。