Skip to content

Commit 3ebb352

Browse files
authored
fix(server): suppression of a potential raised exception with running processes manipulation (jxmorris12#212)
1 parent 9cd9cc0 commit 3ebb352

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

‎CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/2.0.0/),
3434
- Corrected a bug in `language_tool_python.config_file.LanguageToolConfig` where directory paths were incorrectly rejected by the path validator.
3535
- Fixed a bug in `LanguageTool._start_server_on_free_port` where `_url` was not updated when retrying on a different port, causing all subsequent server requests to target the wrong (original) port.
3636
- Fixed a bug in `LanguageTool._query_server` where `RateLimitError` was only raised when the rate-limit response body was invalid JSON, a valid JSON body with status 426 was silently returned as data instead (for now, the body from LanguageTool for rate-limiting responses is "Upgrade Required", which is not valid JSON, but this may change in the future).
37+
- Fixed a bug in `LanguageTool._terminate_server` where `_RUNNING_SERVER_PROCESSES.remove()` could raise `ValueError` if the server process was not yet in the list or was no longer in it.
3738

3839
### Removed
3940
- **Breaking:** Removed all functions and classes previously deprecated in v3.3.0:

‎src/language_tool_python/server.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1226,7 +1226,8 @@ def _terminate_server(self) -> None:
12261226
if self._server:
12271227
logger.info("Terminating LanguageTool server on port %s", self._port)
12281228
_kill_processes([self._server])
1229-
_RUNNING_SERVER_PROCESSES.remove(self._server)
1229+
with contextlib.suppress(ValueError):
1230+
_RUNNING_SERVER_PROCESSES.remove(self._server)
12301231

12311232
if self._server.stdin:
12321233
self._server.stdin.close()

0 commit comments

Comments
 (0)