Merge pull request #21 from scgbckbone/simulator_remove_failed_sock_files

Simulator: remove unused socket files
This commit is contained in:
doc-hex 2022-05-19 08:17:31 -04:00 committed by GitHub
commit 26e7caaab0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 4 deletions

3
.gitignore vendored
View File

@ -23,3 +23,6 @@ __pycache__/
.idea
*.egg-info
venv/
ENV/

View File

@ -340,15 +340,19 @@ class UnixSimulatorPipe:
self.close()
raise RuntimeError("Cannot connect to simulator. Is it running?")
instance = 0
while instance < 10:
last_err = None
for instance in range(5):
pn = '/tmp/ckcc-client-%d-%d.sock' % (os.getpid(), instance)
try:
self.pipe.bind(pn) # just needs any name
break
except OSError:
instance += 1
except OSError as err:
last_err = err
if os.path.exists(pn):
os.remove(pn)
continue
else:
raise last_err # raise whatever was raised last in the loop
self.pipe_name = pn
atexit.register(self.close)