python多线程请求接口_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) :

你可能感兴趣的:(python多线程请求接口)