Don't constantly retry socket
This commit is contained in:
parent
28a127b619
commit
c17484b0ec
1 changed files with 1 additions and 7 deletions
|
@ -22,13 +22,7 @@ WORKER_SERVER_SOCKET = os.path.join(BASE_SOCKET_DIR, "catfish.sock")
|
||||||
|
|
||||||
def send_to_server(payload):
|
def send_to_server(payload):
|
||||||
with socket.socket(socket.AF_UNIX, type=socket.SOCK_STREAM) as sock:
|
with socket.socket(socket.AF_UNIX, type=socket.SOCK_STREAM) as sock:
|
||||||
while True:
|
sock.connect(WORKER_SERVER_SOCKET)
|
||||||
try:
|
|
||||||
sock.connect(WORKER_SERVER_SOCKET)
|
|
||||||
break
|
|
||||||
except ConnectionRefusedError:
|
|
||||||
time.sleep(0.1)
|
|
||||||
|
|
||||||
sock.sendall(ujson.dumps(payload).encode() + NEW_LINE)
|
sock.sendall(ujson.dumps(payload).encode() + NEW_LINE)
|
||||||
return read_all_from_socket(sock)
|
return read_all_from_socket(sock)
|
||||||
|
|
||||||
|
|
Reference in a new issue