Secoondary program stops program

Hello forum, I am using socket communication to send a secondary program, following this example, but it stops the execution of the main program. I would like to write to logs, but to start, I am writing the status of an output. What am I doing wrong? I send the command through port 30002.

Here is my code in python:

HOST = “192.168.1.5”
PORT = 30002
i = 0
while True:
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
s.connect((HOST, PORT))
data = s.recv(1024)
str_send = b"sec secondaryProgram():\n set_digital_out(1,True)\n end\n"
s.sendall(str_send)
data = s.recv(1024)
time.sleep(1)
i = i +0.01
print(f"Received {data!r}")