3

I am using database backend in django celery. The task information is stored in a table called: celery_taskmeta in database. This is my task:

@celery.task
def file_transfer(password, source12, destination):
    result = subprocess.Popen(['sshpass', '-p', password, 'rsync', '-az', source12, destination], 
                                    stderr=subprocess.PIPE, stdout=subprocess.PIPE).communicate()[0]
    return result     

I am calling the task like this:

file_transfer.s(password, source12, destination)

Now I want to show the user the progress of their task and time remaining in the Django template. How can I do that?

pynovice
  • 7,424
  • 25
  • 69
  • 109

1 Answers1

9

Maybe my answer to Django-Celery progress bar is of help (also posted the code to DjangoSnippets, that's how proud I am of that few lines http://djangosnippets.org/snippets/2898/ )

Community
  • 1
  • 1
Florian Sesser
  • 5,972
  • 1
  • 25
  • 26
  • Are you the author? How can I implement this? – pynovice Feb 28 '13 at 11:03
  • Yes I am. I implemented a progress bar for a long-running job using AJAX by polling (0.5s interval) the poll_state view and then using the percentage it gives for the 'width' CSS attribute of a inner div (like in
    . Sorry for taking so long BTW, I did not see your question earlier :(
    – Florian Sesser Apr 04 '13 at 14:24
  • Thanks for the snippet, is it possible for you to share the front end code too? – Demonedge May 10 '16 at 03:39
  • Demonedge: I don't have it anymore, I am afraid. IIRC, I just had a div within a div that had its `width` set to the percent value retrieved from the backend every second or so. – Florian Sesser May 10 '16 at 17:00