mirror of
https://github.com/kovidgoyal/kitty.git
synced 2026-09-01 14:53:30 +00:00
Dont print traceback when socket is unexpectedly closed
This commit is contained in:
parent
963d1b58f8
commit
34a7b42063
1 changed files with 9 additions and 1 deletions
|
|
@ -228,6 +228,10 @@ def encode_send(send: Any) -> bytes:
|
|||
return b'\x1bP' + es + b'\x1b\\'
|
||||
|
||||
|
||||
class SocketClosed(EOFError):
|
||||
pass
|
||||
|
||||
|
||||
class SocketIO:
|
||||
|
||||
def __init__(self, to: str):
|
||||
|
|
@ -268,7 +272,7 @@ class SocketIO:
|
|||
if m is None:
|
||||
if monotonic() - st > timeout:
|
||||
raise TimeoutError('Timed out while waiting to read cmd response')
|
||||
raise EOFError('Remote control connection was closed by kitty without any response being received')
|
||||
raise SocketClosed('Remote control connection was closed by kitty without any response being received')
|
||||
return bytes(m.group(1))
|
||||
|
||||
|
||||
|
|
@ -486,10 +490,14 @@ def main(args: List[str]) -> None:
|
|||
except KeyboardInterrupt:
|
||||
sys.excepthook = lambda *a: print('Interrupted by user', file=sys.stderr)
|
||||
raise
|
||||
except SocketClosed as e:
|
||||
raise SystemExit(str(e))
|
||||
raise SystemExit(f'Timed out after {response_timeout} seconds waiting for response from kitty')
|
||||
except KeyboardInterrupt:
|
||||
sys.excepthook = lambda *a: print('Interrupted by user', file=sys.stderr)
|
||||
raise
|
||||
except SocketClosed as e:
|
||||
raise SystemExit(str(e))
|
||||
if no_response:
|
||||
return
|
||||
if not response.get('ok'):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue