Pierre Chapuis
commited on
add timeout for sse_await
Browse files
src/fg.py
CHANGED
@@ -69,9 +69,9 @@ class EditorAPIContext:
|
|
69 |
future = self.sse_futures[jdata["state"]]
|
70 |
future.set_result(jdata)
|
71 |
|
72 |
-
async def sse_await(self, state_id: str) -> None:
|
73 |
future = self.sse_futures[state_id]
|
74 |
-
jdata = await future
|
75 |
if jdata["status"] != "ok":
|
76 |
print("ERROR", jdata)
|
77 |
assert jdata["status"] == "ok"
|
|
|
69 |
future = self.sse_futures[jdata["state"]]
|
70 |
future.set_result(jdata)
|
71 |
|
72 |
+
async def sse_await(self, state_id: str, timeout: float = 60.0) -> None:
|
73 |
future = self.sse_futures[state_id]
|
74 |
+
jdata = await asyncio.wait_for(future, timeout=timeout)
|
75 |
if jdata["status"] != "ok":
|
76 |
print("ERROR", jdata)
|
77 |
assert jdata["status"] == "ok"
|