Pierre Chapuis commited on
Commit
ac375af
·
unverified ·
1 Parent(s): 36640a8

add timeout for sse_await

Browse files
Files changed (1) hide show
  1. src/fg.py +2 -2
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"