summaryrefslogtreecommitdiff
path: root/mp_tool
diff options
context:
space:
mode:
Diffstat (limited to 'mp_tool')
-rw-r--r--mp_tool/web.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/mp_tool/web.py b/mp_tool/web.py
index 39e3010..6891aa5 100644
--- a/mp_tool/web.py
+++ b/mp_tool/web.py
@@ -129,6 +129,8 @@ def eval(url: str, password: str, code: str):
ws = _connect_and_auth(url, password)
ws.send(Constants.ENTER_REPL_MODE)
stdout.write(read_until_eval_or_timeout(ws))
+
+ ws.settimeout(5)
ws.send(code + "\r\n")
result = read_until_eval_or_timeout(ws)
@@ -139,8 +141,11 @@ def eval(url: str, password: str, code: str):
def read_until_eval_or_timeout(ws: websocket.WebSocket):
buf = ""
- while not buf.endswith("\r\n>>> "):
- buf += ws.recv()
+ try:
+ while not buf.endswith("\r\n>>> "):
+ buf += ws.recv()
+ except websocket.WebSocketTimeoutException:
+ pass
return buf