Skip to content

Commit f24d1ef

Browse files
committed
Fix connection error, again
1 parent 7e52f36 commit f24d1ef

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

plover/oslayer/controller.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,16 @@ def is_owner(self):
2727

2828
def force_cleanup(self):
2929
assert not self.is_owner
30-
if PLATFORM != "win" and os.path.exists(self._address):
31-
os.unlink(self._address)
30+
if PLATFORM != "win":
31+
try:
32+
os.unlink(self._address)
33+
except FileNotFoundError:
34+
# possible race condition: a ConnectionResetError might be caused
35+
# by the previous instance dying just as this instance tries to
36+
# connect to it. In that case self._address would have existed
37+
# at the creation of controller but now no longer exists.
38+
# We ignore the error
39+
pass
3240
return True
3341
return False
3442

plover/scripts/main.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ def main():
158158
# Assume the previous instance died, leaving
159159
# a stray socket, try cleaning it...
160160
if not controller.force_cleanup():
161+
log.error('force cleaning failed')
161162
raise
162163
# ...and restart.
163164
code = -1

0 commit comments

Comments
 (0)