激情久久久_欧美视频区_成人av免费_不卡视频一二三区_欧美精品在欧美一区二区少妇_欧美一区二区三区的

腳本之家,腳本語言編程技術及教程分享平臺!
分類導航

Python|VBS|Ruby|Lua|perl|VBA|Golang|PowerShell|Erlang|autoit|Dos|bat|

服務器之家 - 腳本之家 - Python - Python實現的多線程http壓力測試代碼

Python實現的多線程http壓力測試代碼

2020-09-20 10:42toil Python

這篇文章主要介紹了Python實現的多線程http壓力測試代碼,結合實例形式分析了Python多線程操作的相關實現技巧,需要的朋友可以參考下

本文實例講述了Python實現的多線程http壓力測試代碼。分享給大家供大家參考,具體如下:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# Python version 3.3
__author__ = 'Toil'
import sys, getopt
import threading
def httpGet(url, file):
  import http.client
  conn = http.client.HTTPConnection(url)
  conn.request("GET", file)
  r = conn.getresponse()
  #print(r.getheaders())
  while not r.closed:
    r.read(200)
  conn.close()
def Usage():
  print('''
  Options are:
  -c concurrency Number of multiple requests to make
  -u host     The host
  -f file     File on web
  Example: httpget.py -c 100 -u www.example.com -f /
  ''')
if __name__ == '__main__':
  opts, args = getopt.getopt(sys.argv[1:], "hc:u:f:")
  global u, c, f
  for op, value in opts:
    if op == '-c':
      c = int(value)
    elif op == '-u':
      u = value
    elif op == '-f':
      f = value
    elif op == '-h':
      Usage()
      sys.exit(0)
    else:
      sys.exit(0)
  threads = []
  times = c
  print('Test for ', u, f)
  print('waiting...')
  for i in range(0, times):
    t = threading.Thread(target=httpGet(u, f))
    threads.append(t)
  for i in range(0, times):
    threads[i].start()
  for i in range(0, times):
    threads[i].join()

希望本文所述對大家Python程序設計有所幫助。

延伸 · 閱讀

精彩推薦
主站蜘蛛池模板: 免费在线观看毛片视频 | 午夜视频色 | 欧美日韩一| 国产激情网 | 91a在线观看 | 男女一边摸一边做羞羞视频免费 | 久久国产精品网 | 国产精品久久久久久久久岛 | 毛片免费视频 | 97精品视频在线观看 | 中文字幕免费一区 | 久久久久久亚洲国产精品 | aaaaa国产欧美一区二区 | 日本欧美一区二区三区视频麻豆 | 五月婷婷第四色 | 亚洲网站免费看 | 久久伊人国产精品 | 日韩一级网站 | 久草在线最新免费 | 射逼网站 | 欧美日本一| 欧美性精品videofree | 国人精品视频在线观看 | 美女黄污视频 | 久久久久久久.comav | 国产一级一级片 | 国产精品1区,2区,3区 | 成年男女免费视频 | 久久观看免费视频 | 高清做爰免费无遮网站挡 | 污污短视频 | 成人免费久久 | 青久草视频 | av影院在线| 精品一区二区6 | 中文字幕国产亚洲 | 亚洲国产高清视频 | 草莓福利社区在线 | 国产日韩久久久久69影院 | 久久久久久精 | 午夜久|