Skip to content

Commit fc235f9

Browse files
committed
fix: locust
1 parent fef3da5 commit fc235f9

1 file changed

Lines changed: 33 additions & 31 deletions

File tree

tests/locustfile.py

Lines changed: 33 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
import time
22
import json
3-
from locust import task
3+
from locust import task, HttpUser
44
from locust_plugins.users.socketio import SocketIOUser
5+
import random
56

6-
7-
class MySocketIOUser(SocketIOUser):
8-
9-
7+
# class MySocketIOUser(SocketIOUser):
8+
class QuickstartUser(HttpUser):
9+
def __init__(self, *args, **kwargs):
10+
super().__init__(*args, **kwargs)
11+
self.hashe = str(random.getrandbits(1024))[0:10]
12+
1013
@task(1)
1114
def join_queue(self):
1215
self.client.post(
13-
"/arene/gradio_api/queue/join?cgu_acceptees=",
16+
"/arene/gradio_api/queue/join",
1417
headers={
1518
'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:133.0) Gecko/20100101 Firefox/133.0',
1619
'Accept': '*/*',
@@ -36,36 +39,35 @@ def join_queue(self):
3639
"event_data": None,
3740
"fn_index": 0,
3841
"trigger_id": None,
39-
"session_hash": "ysphayg5fj"
42+
"session_hash": self.hashe
4043
}
4144
)
4245

43-
@task(2)
44-
def get_data(self):
45-
self.client.get(
46-
"/arene/gradio_api/queue/data?session_hash=ysphayg5fj",
47-
headers={
48-
'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:133.0) Gecko/20100101 Firefox/133.0',
49-
'Accept': 'text/event-stream',
50-
'Accept-Language': 'fr,fr-FR;q=0.8,en-US;q=0.5,en;q=0.3',
51-
'Accept-Encoding': 'gzip, deflate, br, zstd',
52-
'Referer': 'http://localhost:8001/arene/?cgu_acceptees',
53-
'Content-Type': 'application/json',
54-
'DNT': '1',
55-
'Connection': 'keep-alive',
56-
'Sec-Fetch-Dest': 'empty',
57-
'Sec-Fetch-Mode': 'cors',
58-
'Sec-Fetch-Site': 'same-origin',
59-
'Sec-GPC': '1',
60-
'Priority': 'u=4'
61-
}
62-
)
63-
6446
# @task(2)
47+
# def get_data(self):
48+
# self.client.get(f"/arene/gradio_api/queue/data?session_hash={self.hashe}",
49+
# headers={
50+
# 'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:133.0) Gecko/20100101 Firefox/133.0',
51+
# 'Accept': 'text/event-stream',
52+
# 'Accept-Language': 'fr,fr-FR;q=0.8,en-US;q=0.5,en;q=0.3',
53+
# 'Accept-Encoding': 'gzip, deflate, br, zstd',
54+
# 'Referer': 'http://localhost:8001/arene/?cgu_acceptees',
55+
# 'Content-Type': 'application/json',
56+
# 'DNT': '1',
57+
# 'Connection': 'keep-alive',
58+
# 'Sec-Fetch-Dest': 'empty',
59+
# 'Sec-Fetch-Mode': 'cors',
60+
# 'Sec-Fetch-Site': 'same-origin',
61+
# 'Sec-GPC': '1',
62+
# 'Priority': 'u=4'
63+
# }
64+
# )
65+
66+
# @task(1)
6567
# def my_task(self):
6668
# self.my_value = None
6769

68-
# self.connect("ws://127.0.0.1:8001/arene/queue/join")
70+
# self.connect("ws://127.0.0.1:8001/arene/gradio_api/queue/join")
6971
# # example of subscribe
7072
# import random
7173

@@ -93,8 +95,8 @@ def get_data(self):
9395
# # wait for additional pushes, while occasionally sending heartbeats, like a real client would
9496
# self.sleep_with_heartbeat(10)
9597

96-
def on_message(self, message):
97-
self.my_value = json.loads(message)
98+
# def on_message(self, message):
99+
# self.my_value = json.loads(message)
98100

99101
# if __name__ == "__main__":
100102
# host = "ws://localhost:8001/queue/test"

0 commit comments

Comments
 (0)