I am building a django app under docker. In the views I call a task where paramiko makes a ssh connection from a container to another to run a third party app. The problem is that during the call to the other container I zip the 'results' folder and move it to another place. This requires a bit. The code though goes back to the views and looks for the zip file before it appears where it should be.
tasks.py
@shared_task()
def my_task():
command2 = f"""sudo cp /.../ibt1.msh /.../ibt1.msh && \n
until sudo zip -r result.zip ./output/; do sleep 5; done && \n
until sudo mv result.zip /europlexusData/result.zip; do sleep 5; done && \n
sudo rm -rf ./output
"""
host2 = "+"
port = ++
username = "+"
password = "+"
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(host2, port, username, password)
stdin, stdout, stderror = ssh.exec_command(command2, get_pty=True)
return 'Done'
views.py
my_task.delay()
file=open('zip/file/to/be/created/in/the/task')
return FileResponse(file)