From 36766a5c233f81cfe58bf57f58875ca97f027fab Mon Sep 17 00:00:00 2001 From: avirgovi Date: Wed, 18 May 2022 15:07:54 +0200 Subject: [PATCH] remove non-used resources; update gitignore with virtualenvs; try only 5 times instead of 10 --- .gitignore | 3 +++ ckcc/client.py | 12 ++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 07f0e51..ac02dfe 100644 --- a/.gitignore +++ b/.gitignore @@ -23,3 +23,6 @@ __pycache__/ .idea *.egg-info + +venv/ +ENV/ \ No newline at end of file diff --git a/ckcc/client.py b/ckcc/client.py index e51a15e..9b2dfcd 100644 --- a/ckcc/client.py +++ b/ckcc/client.py @@ -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)