forking a process within a django view
NickName:BostonJohn Ask DateTime:2014-01-07T04:28:05

forking a process within a django view

I have a webservice that initiates a process that can take up to a minute. I want to return a 204 that effectively says, "I have successfully gotten your request," but run the slow process in the background.

I am trying to do this by forking another process like this:

p = Process(target = modelObj.slowProcess) 
p.start()
logger.debug('sending 204')
return HttpResponse( status=204)

This part of the code seems to execute fine, but is tripping up django components. The debug statement is printed, and the process executes, but when I look at the network traffic in chrome's debugger, it says that the upload status is "cancelled". Since I haven't cancelled the event on the browser side, I assume that means the connection died. I never get any response back from the server, so it seems that I'm somehow breaking the request process.

How can I fork that separate process and still have the 204 get delivered?

Copyright Notice:Content Author:「BostonJohn」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/20958666/forking-a-process-within-a-django-view

More about “forking a process within a django view” related questions

forking a process within a django view

I have a webservice that initiates a process that can take up to a minute. I want to return a 204 that effectively says, "I have successfully gotten your request," but run the slow process in the

Show Detail

Forking Django DB connections

I have an application which receives data over a TCP connection and writes it to a postgres database. I then use a django web front end to provide a gui to this data. Since django provides useful

Show Detail

How to fork a process in python/django?

This is more of a Python general question however in a context of django. For now I have this view in django which has to process a lot of data. Usually it takes the server (nginx with django runn...

Show Detail

Process Forking with PHP

I have copied the below code and on running the code it always shows parent as output.But the source file says it will display output as child parent .Please advice me "How to implem...

Show Detail

Prevent forking in a child process

I have a Linux process (C program) which spawns a couple of child processes. I'd like to forbid another forking in those child processes on the system level, so that those processes would get kille...

Show Detail

Phusion Passenger process stuck on (forking...) Rails

Today I updated to the newest updated package for Nginx and Passenger. After the update, my app now has a (forking...) process that wasn't there before and doesn't seem to go away. Yet it is taking...

Show Detail

Handle computationally-intensive requests to a Django web application, possibly using a pre-forking RPC server

I am running a Django-based webservice with Gunicorn behind nginx as a reverse proxy. My webservice provides a Django view which performs calculations using an external instance of MATLAB. Becaus...

Show Detail

Ruby and Forking

Quick question about Ruby forking - I ran across a bit of forking code in Resque earlier that was sexy as hell but tripped me up for a few. I'm hoping for someone to give me a little more detail ...

Show Detail

Is there a way to run JMH without forking a new java process?

I'm working on a spring project. It has to perform several DB operations (in several methods) while running. I want to measure the exact execution time of some methods in my project(while running)....

Show Detail

Forking a process for simple shell

I am writing a simple shell that needs to execute certain commands for a school assignment. I've been mainly running the commands through the use of the system command. However the assignment has a

Show Detail