html tool

2014年10月9日星期四

多线程启动不同python脚本eg


多线程启动不同python脚本eg,上源码,不多说
----------------------------------------

# -*- coding: UTF8 -*-
import subprocess
import sys,time
import string
import thread
def test_p(_filepath):
 am_filepath=_filepath#"F:\\pc\\working\\test_selenium\\webIM\\addmessage.py"
 subprocess.call("python "+am_filepath)# 启动制定文件

#thread.start_new_thread( test_p,("F:\\pc\\working\\test_selenium\\webIM\\addmessage.py",) )
# add: http://www.w3cschool.cc/python/python-multithreading.html
# 创建两个线程
try:
 thread.start_new_thread( test_p,("F:\\pc\\working\\test_selenium\\webIM\\login_add.py",) )
 thread.start_new_thread( test_p,("F:\\pc\\working\\test_selenium\\webIM\\addmessage.py",) )
    #thread.start_new_thread( test_p,("F:\\pc\\working\\test_selenium\\webIM\\log_add.py",) )
 #thread.start_new_thread( test_p,("F:\\pc\\working\\test_selenium\\webIM\\addmessage_20008701.py",) )

except:
 print "Error: unable to start thread"

while 1:
 pass
#test_p()


没有评论:

发表评论