Spaces:
Build error
Build error
Commit
·
e3c12f6
1
Parent(s):
b6fccf5
Update app.py
Browse files
app.py
CHANGED
|
@@ -9,17 +9,14 @@ import gradio as gr
|
|
| 9 |
host = "wss://spaces.huggingface.tech/farukozderim/test-new-queue/queue/join"
|
| 10 |
duration_list = []
|
| 11 |
|
| 12 |
-
async def startup(client_count):
|
| 13 |
-
client_count = int(client_count)
|
| 14 |
begin = time.time()
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
await asyncio.gather(*[client(i) for i in range(client_count)])
|
| 18 |
end = time.time()
|
| 19 |
return f"Total-duration: {round(end-begin,3)}, success: {len(duration_list)} out of {client_count}"
|
| 20 |
|
| 21 |
-
async def client(rank):
|
| 22 |
-
await asyncio.sleep(rank*
|
| 23 |
async with websockets.connect(host, timeout=10000) as websocket:
|
| 24 |
start = time.time()
|
| 25 |
while True:
|
|
@@ -40,4 +37,5 @@ async def client(rank):
|
|
| 40 |
duration_list.append([duration, start, end])
|
| 41 |
return
|
| 42 |
|
| 43 |
-
|
|
|
|
|
|
| 9 |
host = "wss://spaces.huggingface.tech/farukozderim/test-new-queue/queue/join"
|
| 10 |
duration_list = []
|
| 11 |
|
| 12 |
+
async def startup(client_count, interval_duration):
|
|
|
|
| 13 |
begin = time.time()
|
| 14 |
+
await asyncio.gather(*[client(i, interval_duration) for i in range(client_count)])
|
|
|
|
|
|
|
| 15 |
end = time.time()
|
| 16 |
return f"Total-duration: {round(end-begin,3)}, success: {len(duration_list)} out of {client_count}"
|
| 17 |
|
| 18 |
+
async def client(rank, interval_duration):
|
| 19 |
+
await asyncio.sleep(rank*interval_duration) # Server cannot handle a lot of instantanous conns
|
| 20 |
async with websockets.connect(host, timeout=10000) as websocket:
|
| 21 |
start = time.time()
|
| 22 |
while True:
|
|
|
|
| 37 |
duration_list.append([duration, start, end])
|
| 38 |
return
|
| 39 |
|
| 40 |
+
describe = f'Sends x number of events(requests) with y second intervals to the another space, https://huggingface.co/spaces/farukozderim/test-new-queue'
|
| 41 |
+
gr.Interface(startup, ["number", "number"], "text", description=describe).launch()
|