Close socket earlier

Signed-off-by: fly <merspieler@airmail.cc>
This commit is contained in:
fly 2020-02-13 15:16:38 +00:00
parent 88264683d3
commit 0d79de004d

View file

@ -92,6 +92,7 @@ def get_job(action):
sock.connect((host, port)) sock.connect((host, port))
sock.send(("get " + action).encode()) sock.send(("get " + action).encode())
msg = sock.recv(128) msg = sock.recv(128)
sock.close()
msg = msg.decode() msg = msg.decode()
match = re.match(r"n-pole|s-pole|[ew]\d{3}[ns]\d{2}|None", msg) match = re.match(r"n-pole|s-pole|[ew]\d{3}[ns]\d{2}|None", msg)
if match != None: if match != None:
@ -103,7 +104,6 @@ def get_job(action):
print("Recived invalid job. Retrying in 10 seconds...") print("Recived invalid job. Retrying in 10 seconds...")
sleep(10) sleep(10)
ret = get_job(action) ret = get_job(action)
sock.close()
return ret return ret
except IOError: except IOError:
print("Unable to get job. Retrying in 10 seconds...") print("Unable to get job. Retrying in 10 seconds...")