kore

Kore is a web application platform for writing scalable, concurrent web based processes in C or Python.
Commits | Files | Refs | README | LICENSE | git clone https://git.kore.io/kore.git

commit 89e58fa474c9a1ef33f8ea904f5d1029df942f1e
parent 93b1d621d7fac629ddf8047f0e59f299710f5bc2
Author: Joris Vink <joris@coders.se>
Date:   Wed,  5 Jun 2019 10:35:47 +0200

Improve iterator support for Python req.response().

If the connection on which we are about to send the response was
marked as disconnecting, do not go ahead and hook into the disconnect
callback (it will never be called, it is already disconnecting).

Instead just return, the connection will be removed anyway.

Diffstat:
src/python.c | 7+++++--
1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/python.c b/src/python.c @@ -3159,11 +3159,14 @@ pyhttp_response(struct pyhttp_request *pyreq, PyObject *args) } else if (obj == Py_None) { http_response(pyreq->req, status, NULL, 0); } else { + c = pyreq->req->owner; + if (c->state == CONN_STATE_DISCONNECTING) { + Py_RETURN_FALSE; + } + if ((iterator = PyObject_GetIter(obj)) == NULL) return (NULL); - c = pyreq->req->owner; - iterobj = kore_pool_get(&iterobj_pool); iterobj->iterator = iterator; iterobj->connection = c;