Note that there are some explanatory texts on larger screens.

plurals
  1. POtrigger function after returning HttpResponse from django view
    primarykey
    data
    text
    <p>I am developing a django webserver on which another machine (with a known IP) can upload a spreadsheet to my webserver. <strong>After</strong> the spreadsheet has been updated, I want to trigger some processing/validation/analysis on the spreadsheet (which can take >5 minutes --- too long for the other server to reasonably wait for a response) and then send the other machine (with a known IP) a HttpResponse indicating that the data processing is finished.</p> <p>I realize that you can't do <code>processing.data()</code> after returning an <code>HttpResponse</code>, but functionally I want code that looks something like this:</p> <pre><code># processing.py def spreadsheet(*args, **kwargs): print "[robot voice] processing spreadsheet........." views.finished_processing_spreadsheet() # views.py def upload_spreadsheet(request): print "save the spreadsheet somewhere" return HttpResponse("started processing spreadsheet") processing.data() def finished_processing_spreadsheet(): print "send good news to other server (with known IP)" </code></pre> <p>I know how to write each function individually, but how can I effectively call <code>processing.data()</code> <strong>after</strong> <code>views.upload_spreadsheet</code> has returned a response?</p> <p>I tried using <a href="https://docs.djangoproject.com/en/dev/ref/signals/#django.core.signals.request_finished">django's <code>request_finished</code> signaling framework</a> but this does not trigger the <code>processing.spreadsheet()</code> method after returning the <code>HttpResponse</code>. I tried using a decorator on <code>views.upload_spreadsheet</code> with the same problem. </p> <p>I have an inkling that this might have something to do with writing <a href="https://docs.djangoproject.com/en/dev/topics/http/middleware">middleware</a> or possibly a <a href="https://docs.djangoproject.com/en/dev/topics/class-based-views/">custom class-based view</a>, neither of which I have any experience with so I thought I would pose the question to the universe in search of some help.</p> <p>Thanks for your help!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload