Skip to content

Commit faf298a

Browse files
committed
Fix connection error, again
1 parent 497a362 commit faf298a

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
@@ -28,8 +28,16 @@ def is_owner(self):
2828

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

plover/scripts/main.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ def main():
135135
# Assume the previous instance died, leaving
136136
# a stray socket, try cleaning it...
137137
if not controller.force_cleanup():
138+
log.error('force cleaning failed')
138139
raise
139140
# ...and restart.
140141
code = -1

0 commit comments

Comments
 (0)