Skip to content

Commit 5160c9a

Browse files
authored
On a dmypy crash, report the crash to the client (#4769)
1 parent b497216 commit 5160c9a

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

mypy/dmypy_server.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,14 @@ def serve(self) -> None:
162162
resp = {'error': "Command is not a string"}
163163
else:
164164
command = data.pop('command')
165-
resp = self.run_command(command, data)
165+
try:
166+
resp = self.run_command(command, data)
167+
except Exception:
168+
# If we are crashing, report the crash to the client
169+
tb = traceback.format_exception(*sys.exc_info()) # type: ignore
170+
resp = {'error': "Daemon crashed!\n" + "".join(tb)}
171+
conn.sendall(json.dumps(resp).encode('utf8'))
172+
raise
166173
try:
167174
conn.sendall(json.dumps(resp).encode('utf8'))
168175
except OSError as err:

0 commit comments

Comments
 (0)