码迷,mamicode.com
首页 > 编程语言 > 详细

python接口并发

时间:2018-07-19 13:51:47      阅读:363      评论:0      收藏:0      [点我收藏+]

标签:sts   daemon   end   time   utf-8   __name__   min   username   pre   

一、同一用户并发上传不同文件内容

#coding=utf-8
import requests
import threading
from time import ctime,time

# D:\\code\\budget_test\\api\\1.xlsx‘
filelist=[‘C:\\Users\\53843\\Desktop\\1.xlsx‘,
          ‘C:\\Users\\53843\\Desktop\\2.xlsx‘
          ]
def t1(filedir):
    data1 = {
    ‘username‘:"admin",
    ‘password‘:"111",
    ‘loginbutton‘:"登 录"
    }
    s = requests.session()
    s.post(url=‘http://172.16.1.64:8080/business-analysis-1.0/a/login‘,data=data1)
    print ("I was at the %s " %ctime())
    files={‘file‘: open(filedir, ‘rb‘)}
    print ("I was at the %s start!" %ctime())
    r=s.post(url=‘http://172.16.1.64:8080/business-analysis-1.0/a/budget/budgetHead/excelTodata‘,files=files)
    print(r.text)

threads=[]
nub=2
for i in range(2):
    threads.append(threading.Thread(target = t1(filelist[i])))
if __name__==‘__main__‘:
    for t in threads:
        t.setDaemon(True)
        t.start()
    t.join()
    print("all over %s"%ctime())
  

  

python接口并发

标签:sts   daemon   end   time   utf-8   __name__   min   username   pre   

原文地址:https://www.cnblogs.com/szmcn/p/9334864.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!