Commit 6005cc36 authored by Robert Dietrich's avatar Robert Dietrich

improved error handling for redis connections

parent a4a363b4
......@@ -28,18 +28,29 @@ def main(job_id, debug_path, env_file, force):
debug_file = open(debug_file_path,'w')
debug_file.write("debug before: {0} {1}\n".format(job_id, time.time()))
slurm_env_string = None
haveConnectionError = False
try:
slurm_env_string = connection.get("prope_" + str(job_id))
except: # redis.exceptions.TimeoutError:
haveConnectionError = True
t = 0
slurm_env_string = connection.get("prope_" + str(job_id))
while slurm_env_string == None and t < 10:
slurm_env_string = connection.get("prope_" + str(job_id))
try:
slurm_env_string = connection.get("prope_" + str(job_id))
except: # redis.exceptions.TimeoutError:
haveConnectionError = True
continue
sleep(1)
t = t + 1
t = t + 1
#pprint(slurm_env_string)
if debug_path and debug_file:
time_attemps = "Time attemps = " + str(t) + str("\n")
debug_file.write(time_attemps)
if debug_file:
if haveConnectionError:
debug_file.write("Redis connection error ocurred!\n")
debug_file.write("Connection attemps = {:d}\n".format(t))
debug_file.write("debug after: {0} {1}\n".format(job_id, time.time()))
#f.close()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment