Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Ensure recovery from BrokenPipeError #563

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

krassowski
Copy link
Member

References

Fixes part of #20, and maybe #274. Well, it does not work yet (if I remember correctly), but the tests might come in handy.

Code changes

User-facing changes

Backwards-incompatible changes

Chores

  • linted
  • tested
  • documented
  • changelog entry

@krassowski krassowski added the help wanted Extra attention is needed label Mar 23, 2021
@doodleEsc
Copy link

doodleEsc commented Jun 17, 2021

  183 class LspStdIoWriter(LspStdIoBase):
  184     """Language Server stdio Writer"""
  185
  186     async def write(self) -> None:
  187         """Write to a Language Server until it closes"""
  188         while not self.stream.closed:
  189             message = await self.queue.get()
  190             try:
  191                 body = message.encode("utf-8")
  192                 response = "Content-Length: {}\r\n\r\n{}".format(len(body), message)
  193                 await convert_yielded(self._write_one(response.encode("utf-8")))
  194             except BrokenPipeError:
  195                 #  self.queue.task_done()
  196                 # propagate broken pipe errors
  197                 raise
  198             except Exception:  # pragma: no cover
  199                 # catch other (hopefully mild) exceptions
  200                 self.log.exception("%s couldn't write message: %s", self, response)
  201             finally:
  202                 self.queue.task_done()
  203
  204     @run_on_executor
  205     def _write_one(self, message) -> None:
  206         self.stream.write(message)
  207         self.stream.flush()

Hi @krassowski , I delete the code at line 195 in stdio.py, and it works

  1. self.queue.task_done() is called twice, and the BrokenPipeError will be covered by ValueError("task_done() called too many times").
  2. The function _write_lsp does not catch BrokenPipeError,then the process will not be initialize again.

#563 #20 #274

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants