diff --git a/core/io.c b/core/io.c index 5e187799..a771e91a 100644 --- a/core/io.c +++ b/core/io.c @@ -1092,3 +1092,8 @@ void uwsgi_disconnect(struct wsgi_request *wsgi_req) { } wsgi_req->fd_closed = 1; } + +int uwsgi_ready_fd(struct wsgi_request *wsgi_req) { + if (wsgi_req->async_ready_fd) return wsgi_req->async_last_ready_fd; + return -1; +} diff --git a/plugins/pypy/pypy_setup.py b/plugins/pypy/pypy_setup.py index f9ea21d3..dc59a60a 100644 --- a/plugins/pypy/pypy_setup.py +++ b/plugins/pypy/pypy_setup.py @@ -212,6 +212,8 @@ char *uwsgi_chunked_read(struct wsgi_request *, size_t *, int, int); void uwsgi_disconnect(struct wsgi_request *); +int uwsgi_ready_fd(struct wsgi_request *); + %s ''' % ('\n'.join(uwsgi_cdef), hooks) @@ -702,9 +704,7 @@ uwsgi.ready_fd() """ def uwsgi_pypy_ready_fd(): wsgi_req = uwsgi_pypy_current_wsgi_req(); - if wsgi_req.async_ready_fd == 1: - return wsgi_req.async_last_ready_fd - return -1 + return lib.uwsgi_ready_fd(wsgi_req) uwsgi.ready_fd = uwsgi_pypy_ready_fd diff --git a/plugins/python/uwsgi_pymodule.c b/plugins/python/uwsgi_pymodule.c index 34ffdde3..ffe15ce6 100644 --- a/plugins/python/uwsgi_pymodule.c +++ b/plugins/python/uwsgi_pymodule.c @@ -2276,6 +2276,11 @@ PyObject *py_uwsgi_disconnect(PyObject * self, PyObject * args) { return Py_None; } +PyObject *py_uwsgi_ready_fd(PyObject * self, PyObject * args) { + struct wsgi_request *wsgi_req = py_current_wsgi_req(); + return PyInt_FromLong(uwsgi_ready_fd(wsgi_req)); +} + PyObject *py_uwsgi_parse_file(PyObject * self, PyObject * args) { char *filename; @@ -2516,6 +2521,8 @@ static PyMethodDef uwsgi_advanced_methods[] = { {"chunked_read", py_uwsgi_chunked_read, METH_VARARGS, ""}, {"chunked_read_nb", py_uwsgi_chunked_read_nb, METH_VARARGS, ""}, + {"ready_fd", py_uwsgi_ready_fd, METH_VARARGS, ""}, + {NULL, NULL}, }; diff --git a/uwsgi.h b/uwsgi.h index c2b1e674..7cf12d8e 100644 --- a/uwsgi.h +++ b/uwsgi.h @@ -4071,6 +4071,7 @@ char *uwsgi_binary_path(void); int uwsgi_is_again(); void uwsgi_disconnect(struct wsgi_request *); +int uwsgi_ready_fd(struct wsgi_request *); void uwsgi_check_emperor(void); #ifdef UWSGI_AS_SHARED_LIBRARY