Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

提交 Python threading+requests 压力测试示例 #47

Closed
Zerek-Cheng opened this issue Jul 2, 2022 · 4 comments
Closed

提交 Python threading+requests 压力测试示例 #47

Zerek-Cheng opened this issue Jul 2, 2022 · 4 comments

Comments

@Zerek-Cheng
Copy link

Zerek-Cheng commented Jul 2, 2022

# use requests to upload a img
import random
import threading
import time
import uuid

import requests


def doing():
    ret = requests.request(method="POST", url='https://your url/application/upload.php',
                           data={"name": str(random.randint(10000, 99999)) + ".php"
                               , "uuid": uuid.uuid4()}
                           , files={"file": open("C:\\Users\Administrator\\Desktop\\test.jpg", "rb")})
    print(ret.text)


for i in range(1):
    threading.Thread(target=doing).start()
    time.sleep(0.05)
    print(i)

@Zerek-Cheng Zerek-Cheng changed the title 提交 Python threading+requests 压力测试脚本 提交 Python threading+requests 压力测试示例 Jul 2, 2022
@icret
Copy link
Owner

icret commented Jul 3, 2022

# use requests to upload a img
import random
import threading
import time
import uuid

import requests


def doing():
    ret = requests.request(method="POST", url='https://your url/application/upload.php',
                           data={"name": str(random.randint(10000, 99999)) + ".php"
                               , "uuid": uuid.uuid4()}
                           , files={"file": open("C:\\Users\Administrator\\Desktop\\test.jpg", "rb")})
    print(ret.text)


for i in range(1):
    threading.Thread(target=doing).start()
    time.sleep(0.05)
    print(i)

so,这个的作用是什么呢?结果又如何呢?

@jackadam1981
Copy link

就是模拟很多人上传,测试服务器的。

@icret
Copy link
Owner

icret commented Jul 3, 2022

就是模拟很多人上传,测试服务器的。

所以得到的结果是?

@jackadam1981
Copy link

看差了,仔细看代码,这是python异步上传
和压力测试没多大关系。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants