Skip to content

Commit

Permalink
Properly exit ReaderThread on socket shutdown. Fixes microsoft#1942
Browse files Browse the repository at this point in the history
  • Loading branch information
fabioz committed Nov 26, 2019
1 parent d8d0eba commit a34be6a
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/ptvsd/_vendored/pydevd/_pydevd_bundle/pydevd_comm.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,14 +285,15 @@ def _on_run(self):
# processing anything read).
try:
line = self._read_line()
if self._kill_received:
continue

if len(line) == 0:
pydev_log.debug('ReaderThread: empty contents received (len(line) == 0).')
self._terminate_on_socket_close()
return # Finished communication.

if self._kill_received:
continue

if line.startswith(b'Content-Length:'):
content_len = int(line.strip().split(b':', 1)[1])
continue
Expand All @@ -301,8 +302,6 @@ def _on_run(self):
# If we previously received a content length, read until a '\r\n'.
if line == b'\r\n':
json_contents = self._read(content_len)
if self._kill_received:
continue

content_len = -1

Expand All @@ -311,6 +310,9 @@ def _on_run(self):
self._terminate_on_socket_close()
return # Finished communication.

if self._kill_received:
continue

# We just received a json message, let's process it.
self.process_net_command_json(self.py_db, json_contents)

Expand Down

0 comments on commit a34be6a

Please sign in to comment.