【Python】多线程自动发布项目

在原有的自动化项目回归测试项目中利用多线程实现自动发布项目


#coding=utf-8
from selenium import webdriver
from itbt import login,raiseborrow,cancleProject
from itbt.tools import config
import Queue,threading,time
q=Queue.Queue()
t=5

with open('temp.txt','r') as f:
for user in f:
if user != "":
q.put(user.decode('gbk', 'utf-8'))
def borrow():
driver=webdriver.Firefox()
driver.maximize_window()
while not q.empty():
user=q.get()
print user
try:
login.login(driver, user)
cancleProject.cancleProject(driver)
raiseborrow.raise_borrow(driver, 'second')
except:
print user + u'发标失败'
login.quit_login(driver)
driver.quit()

for i in range(t):
t=threading.Thread(target=borrow)
t.start()