Programming in python: Async functions in Django views on newest questions tagged python – Stack Overflow

Is it possible to do something like this:

def new_query(request,company_uuid,address_uuid,contact_uuid):
    mcompany = get_object_or_404(Company, uuid=company_uuid)
    if request.method == 'POST': # If the form has been submitted...
        form = forms.CompanyQueryForm(request.POST)
        if form.is_valid():
            mquery = form.save(commit = False)
            mcompany = get_object_or_404(Company, uuid = company_uuid)
            mquery.company = mcompany
            mquery.version_number = 1
            mquery.parameters = {
                                    'company':company_uuid,
                                    'address':address_uuid,
                                    'contact':contact_uuid
                                    }
            mquery.save()
            preserialise(mquery.pk, company_uuid)
            recent_update = RecentUpdate(company_query=mquery, update_type="1")
            recent_update.save()
            url = reverse('view_directory',kwargs={'company_uuid':company_uuid,
                                                                'address_uuid':address_uuid,
                                                                'contact_uuid':contact_uuid})
            return HttpResponseRedirect(url)
    else:
        form = forms.CompanyQueryForm()
    return share.output_page(request,'joinerysoft/new_query.html',{'title':unicode(u'New Company Query'),
                                                                   'form': form,
                                                                   'company':mcompany,
                                                                   'address_uuid':address_uuid,
                                                                   'contact_uuid':contact_uuid})

where preserialise(mquery.pk, company_uuid) runs in the background without waiting to return? as pre-serialisation takes a long time to complete (over 5 minutes) and I’d like it to be a fire and forget from the perspective of the user.

See Answers


source: http://stackoverflow.com/questions/11632034/async-functions-in-django-views
Programming in python: programming-in-python



online applications demo