Spaces:
Running
Running
clementruhm
commited on
Commit
•
0b2bb7e
1
Parent(s):
ea535b1
Update vc_service_request.py
Browse filesadd timeout while waiting for result
- vc_service_request.py +3 -1
vc_service_request.py
CHANGED
@@ -81,10 +81,12 @@ async def async_service_request(source: np.ndarray, target: np.ndarray) -> np.nd
|
|
81 |
result_lst = []
|
82 |
while True:
|
83 |
try:
|
84 |
-
data = await websocket.recv()
|
85 |
result_lst.append(np.frombuffer(data, dtype="int16"))
|
86 |
except websockets.exceptions.ConnectionClosed:
|
87 |
break
|
|
|
|
|
88 |
if data is None:
|
89 |
break
|
90 |
result = np.concatenate(result_lst) if result_lst else None
|
|
|
81 |
result_lst = []
|
82 |
while True:
|
83 |
try:
|
84 |
+
data = await asyncio.wait_for(websocket.recv(), timeout=15)
|
85 |
result_lst.append(np.frombuffer(data, dtype="int16"))
|
86 |
except websockets.exceptions.ConnectionClosed:
|
87 |
break
|
88 |
+
except asyncio.TimeoutError:
|
89 |
+
break
|
90 |
if data is None:
|
91 |
break
|
92 |
result = np.concatenate(result_lst) if result_lst else None
|