remove non-used resources; update gitignore with virtualenvs; try only 5 times instead of 10

This commit is contained in:
avirgovi 2022-05-18 15:07:54 +02:00
parent 9abbe10db4
commit 36766a5c23
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)