当前位置:   article > 正文

python多线程请求接口_python多线程实现http请求

python多线程请求http

#!/usr/bin python2.6

# -*- coding: utf-8 -*-

import threading, datetime, time, httplib

# 初始最大并发数

START_THEAD_COUNT = 200

# 递增并发数

THREAD_INCREASE_STEP = 10

# 域名

DOMAIN = 'www.baidu.com'

# 默认http请求

METHOD = 'get'

# 默认访问的web路径

PATH = '/'

# 请求发送间隔 整数

INTERVAL = 5  # 5秒

'''Factory'''

class biz :

'''Main'''

def run(self) :

start = datetime.datetime.now()

global FAILED_COUNT

FAILED_COUNT = 0

threads = []

# thread instance initialization

for i in range(START_THEAD_COUNT) :

t=threading.Thread(target=self.execute, args=())

threads.append(t)

# activate threads

for i in range(START_THEAD_COUNT) :</

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/繁依Fanyi0/article/detail/172483
推荐阅读
相关标签
  

闽ICP备14008679号