forked from DGNum/uptime-kuma-api
🐛 (api.py): Raise correct error when timeout
This commit is contained in:
parent
be97a4fd8f
commit
91ad893223
1 changed files with 7 additions and 4 deletions
|
@ -500,11 +500,14 @@ class UptimeKumaApi(object):
|
||||||
return deepcopy(self._event_data[event].copy())
|
return deepcopy(self._event_data[event].copy())
|
||||||
|
|
||||||
def _call(self, event, data=None) -> Any:
|
def _call(self, event, data=None) -> Any:
|
||||||
r = self.sio.call(event, data, timeout=self.timeout)
|
try:
|
||||||
if isinstance(r, dict) and "ok" in r:
|
r = self.sio.call(event, data, timeout=self.timeout)
|
||||||
if not r["ok"]:
|
|
||||||
raise UptimeKumaException(r.get("msg"))
|
|
||||||
r.pop("ok")
|
r.pop("ok")
|
||||||
|
except socketio.exceptions.TimeoutError:
|
||||||
|
raise Timeout(f"Timed out while waiting for event {event}")
|
||||||
|
except Exception as e:
|
||||||
|
raise UptimeKumaException(r.get("msg"))
|
||||||
|
|
||||||
return r
|
return r
|
||||||
|
|
||||||
# event handlers
|
# event handlers
|
||||||
|
|
Loading…
Reference in a new issue