python fixes and optimizations

This commit is contained in:
roberto@sirius
2010-10-29 13:02:59 +02:00
parent 8971539550
commit 32ab7e79ca
11 changed files with 56 additions and 104 deletions
+3 -6
View File
@@ -286,12 +286,11 @@ int uwsgi_request_wsgi(struct wsgi_request *wsgi_req) {
wsgi_req->async_result = wi->request_subhandler(wsgi_req, wi);
if (wsgi_req->async_result) {
UWSGI_RELEASE_GIL
while ( (*wi->response_subhandler)(wsgi_req) != UWSGI_OK) {
while ( wi->response_subhandler(wsgi_req) != UWSGI_OK) {
wsgi_req->switches++;
#ifdef UWSGI_ASYNC
if (uwsgi.async > 1) {
@@ -336,7 +335,6 @@ int uwsgi_request_wsgi(struct wsgi_request *wsgi_req) {
close(tmp_stderr);
}
clear:
UWSGI_GET_GIL
@@ -353,10 +351,9 @@ clear:
UWSGI_RELEASE_GIL
clear2:
clear2:
return UWSGI_OK;
return UWSGI_OK;
}
+1
View File
@@ -149,6 +149,7 @@ PyObject *py_uwsgi_spit(PyObject * self, PyObject * args) {
uwsgi_error("writev()");
}
//uwsgi_log("%d %p\n", wsgi_req->poll.fd, up.wsgi_writeout);
Py_INCREF(up.wsgi_writeout);
+9 -9
View File
@@ -110,15 +110,15 @@ int uwsgi_response_subhandler_wsgi(struct wsgi_request *wsgi_req) {
UWSGI_GET_GIL
// return or yield ?
if (PyString_Check((PyObject *)wsgi_req->async_result)) {
if ((wsize = write(wsgi_req->poll.fd, PyString_AsString(wsgi_req->async_result), PyString_Size(wsgi_req->async_result))) < 0) {
uwsgi_error("write()");
goto clear;
}
wsgi_req->response_size += wsize;
// return or yield ?
if (PyString_Check((PyObject *)wsgi_req->async_result)) {
if ((wsize = write(wsgi_req->poll.fd, PyString_AsString(wsgi_req->async_result), PyString_Size(wsgi_req->async_result))) < 0) {
uwsgi_error("write()");
goto clear;
}
wsgi_req->response_size += wsize;
goto clear;
}
#ifdef UWSGI_SENDFILE
if (wsgi_req->sendfile_obj == wsgi_req->async_result && wsgi_req->sendfile_fd != -1) {
@@ -181,7 +181,7 @@ int uwsgi_response_subhandler_wsgi(struct wsgi_request *wsgi_req) {
Py_DECREF(pychunk);
UWSGI_RELEASE_GIL
return UWSGI_AGAIN;
return UWSGI_AGAIN;
clear:
if (wsgi_req->sendfile_fd != -1) {
@@ -214,7 +214,7 @@ clear2:
#endif
UWSGI_RELEASE_GIL
return UWSGI_OK;
return UWSGI_OK;
}