I have a long running Fabric task (~30mins) executed from Django.
An example code is here:
from django.http import HttpResponse
from fabric.tasks import execute
from fabric.api import sudo
@task
def runcmd():
result = sudo('ls -l')
def executer(request):
result = execute(
runcmd,
hosts=['localhost']
)
return HttpResponse(result['localhost'])
The problem here I don't want to wait to show the logs (stdout) for 30 minutes. I can get the result after the task completed. I just need the capture stdout while the task is running and send it to client.
I tried StreamingHttpResponse and ajax but didn't worked.
How can I solve this or is there any alternatives for that?
Regards,