From f24d1ef0bbcb2240bbfecc58d003fa3e4144f244 Mon Sep 17 00:00:00 2001 From: user202729 <25191436+user202729@users.noreply.github.com> Date: Thu, 17 Jul 2025 19:51:08 +0700 Subject: [PATCH 1/3] Fix connection error, again --- plover/oslayer/controller.py | 12 ++++++++++-- plover/scripts/main.py | 1 + 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/plover/oslayer/controller.py b/plover/oslayer/controller.py index 70cd138eb..badc1cee3 100644 --- a/plover/oslayer/controller.py +++ b/plover/oslayer/controller.py @@ -27,8 +27,16 @@ def is_owner(self): def force_cleanup(self): assert not self.is_owner - if PLATFORM != "win" and os.path.exists(self._address): - os.unlink(self._address) + if PLATFORM != "win": + try: + os.unlink(self._address) + except FileNotFoundError: + # possible race condition: a ConnectionResetError might be caused + # by the previous instance dying just as this instance tries to + # connect to it. In that case self._address would have existed + # at the creation of controller but now no longer exists. + # We ignore the error + pass return True return False diff --git a/plover/scripts/main.py b/plover/scripts/main.py index b7a5a9773..f099f4f49 100644 --- a/plover/scripts/main.py +++ b/plover/scripts/main.py @@ -158,6 +158,7 @@ def main(): # Assume the previous instance died, leaving # a stray socket, try cleaning it... if not controller.force_cleanup(): + log.error('force cleaning failed') raise # ...and restart. code = -1 From fdceffe209b29b797c91310b40edef47f0752aa4 Mon Sep 17 00:00:00 2001 From: user202729 <25191436+user202729@users.noreply.github.com> Date: Thu, 17 Jul 2025 19:53:31 +0700 Subject: [PATCH 2/3] Add news entry --- news.d/bugfix/1743.core.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 news.d/bugfix/1743.core.md diff --git a/news.d/bugfix/1743.core.md b/news.d/bugfix/1743.core.md new file mode 100644 index 000000000..e8679f788 --- /dev/null +++ b/news.d/bugfix/1743.core.md @@ -0,0 +1 @@ +Hide `ConnectionResetError` caused by a race condition when Plover is restarted. From e3f86e5dd87a29ed8d066bedd4ac918c23fd6384 Mon Sep 17 00:00:00 2001 From: user202729 <25191436+user202729@users.noreply.github.com> Date: Fri, 18 Jul 2025 08:13:31 +0700 Subject: [PATCH 3/3] Fix ruff --- plover/scripts/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plover/scripts/main.py b/plover/scripts/main.py index f099f4f49..559ed8291 100644 --- a/plover/scripts/main.py +++ b/plover/scripts/main.py @@ -158,7 +158,7 @@ def main(): # Assume the previous instance died, leaving # a stray socket, try cleaning it... if not controller.force_cleanup(): - log.error('force cleaning failed') + log.error("force cleaning failed") raise # ...and restart. code = -1