Version 2.2.9:

Signed-off-by: Jeroen Oudshoorn <oudshoorn.jeroen@gmail.com>
This commit is contained in:
Jeroen Oudshoorn
2023-09-05 21:22:44 +02:00
parent f5be1cc279
commit 7a7b700dad

View File

@ -55,14 +55,14 @@ class Client(object):
logging.exception("Other error while opening websocket (%s) with parameter %s", e, s) logging.exception("Other error while opening websocket (%s) with parameter %s", e, s)
def run(self, command, verbose_errors=True): def run(self, command, verbose_errors=True):
for _ in range(0, 2): for _ in range(0, 2):
try: try:
r = requests.post("%s/session" % self.url, auth=self.auth, json={'cmd': command}) r = requests.post("%s/session" % self.url, auth=self.auth, json={'cmd': command})
except requests.exceptions.ConnectionError as e: except requests.exceptions.ConnectionError as e:
logging.exception("Request connection error (%s) while running command (%s)", e, command) logging.exception("Request connection error (%s) while running command (%s)", e, command)
sleep(1) # Sleep for 1-s before trying a second time sleep(1) # Sleep for 1-s before trying a second time
else: else:
break break
return decode(r, verbose_errors=verbose_errors) return decode(r, verbose_errors=verbose_errors)