In my django piston API, I want to give / return an HTTP response to the client before calling another function, which will take quite a while. How to make the income give an HTTP response containing the desired JSON, and not a line related to the creation of the generator object?
My piston handler method looks like this:
def create(self, request): data = request.data *other operations......................* incident.save() response = rc.CREATED response.content = {"id":str(incident.id)} yield response manage_incident(incident)
Instead of the answer I want, for example:
{"id":"13"}
The client receives the following line:
"<generator object create at 0x102c50050>"
EDIT:
I understand that using the lesson was the wrong way to do this, in fact, I am trying to ensure that the client immediately receives a response before the server switches to the expensive manage_incident () function
source share