mirror of
https://github.com/clearlinux/uwsgi.git
synced 2026-09-07 14:11:46 +00:00
PyPy SUPPORT
This commit is contained in:
@@ -3,14 +3,9 @@
|
||||
extern struct uwsgi_server uwsgi;
|
||||
extern struct uwsgi_python up;
|
||||
|
||||
#ifdef UWSGI_PYPY
|
||||
void gil_real_get() {}
|
||||
void gil_real_release() {}
|
||||
#else
|
||||
|
||||
void gil_real_get() {
|
||||
//uwsgi_log("LOCK %d\n", uwsgi.mywid);
|
||||
#ifndef PYTHREE
|
||||
#if !defined(PYTHREE) && !defined(UWSGI_PYPY)
|
||||
PyEval_AcquireLock();
|
||||
PyThreadState_Swap((PyThreadState *) pthread_getspecific(up.upt_gil_key));
|
||||
#else
|
||||
@@ -22,7 +17,7 @@ void gil_real_get() {
|
||||
|
||||
void gil_real_release() {
|
||||
//uwsgi_log("UNLOCK %d\n", uwsgi.mywid);
|
||||
#ifndef PYTHREE
|
||||
#if !defined(PYTHREE) && !defined(UWSGI_PYPY)
|
||||
pthread_setspecific(up.upt_gil_key, (void *) PyThreadState_Swap(NULL));
|
||||
PyEval_ReleaseLock();
|
||||
#else
|
||||
@@ -31,7 +26,6 @@ void gil_real_release() {
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void gil_fake_get() {}
|
||||
void gil_fake_release() {}
|
||||
|
||||
@@ -483,9 +483,7 @@ PyObject *uwsgi_uwsgi_loader(void *arg1) {
|
||||
|
||||
PyObject *tmp_callable;
|
||||
PyObject *applications;
|
||||
#ifndef UWSGI_PYPY
|
||||
PyObject *uwsgi_dict = get_uwsgi_pydict("uwsgi");
|
||||
#endif
|
||||
|
||||
char *module = (char *) arg1;
|
||||
|
||||
@@ -508,11 +506,8 @@ PyObject *uwsgi_uwsgi_loader(void *arg1) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#ifndef UWSGI_PYPY
|
||||
applications = PyDict_GetItemString(uwsgi_dict, "applications");
|
||||
if (applications && PyDict_Check(applications)) return applications;
|
||||
#endif
|
||||
|
||||
|
||||
applications = PyDict_GetItemString(wsgi_dict, "applications");
|
||||
if (applications && PyDict_Check(applications)) return applications;
|
||||
|
||||
@@ -6,9 +6,16 @@ struct uwsgi_python up;
|
||||
extern struct http_status_codes hsc[];
|
||||
|
||||
#ifdef UWSGI_PYPY
|
||||
char *RPython_StartupCode(void);
|
||||
|
||||
#define pypy_asm_stack_bottom() asm volatile ("/* GC_STACK_BOTTOM */" : : : \
|
||||
"memory")
|
||||
|
||||
char *RPython_StartupCode(void);
|
||||
|
||||
extern struct pypy_pypy_module_cpyext_state_State0 pypy_g_pypy_module_cpyext_state_State;
|
||||
extern struct pypy_pypy_interpreter_baseobjspace_W_Root0 *pypy_g_call_startup(void);
|
||||
void pypy_g_State_startup(struct pypy_pypy_module_cpyext_state_State0 *);
|
||||
|
||||
void Py_Initialize(void) {
|
||||
|
||||
pypy_asm_stack_bottom();
|
||||
@@ -17,6 +24,9 @@ void Py_Initialize(void) {
|
||||
uwsgi_log("unable to initialize PyPy: %s\n", errmsg);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
pypy_g_call_startup();
|
||||
pypy_g_State_startup(&pypy_g_pypy_module_cpyext_state_State);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -712,11 +722,7 @@ void init_uwsgi_embedded_module() {
|
||||
#ifdef UNBIT
|
||||
if (PyDict_SetItemString(up.embedded_dict, "unbit", Py_True)) {
|
||||
#else
|
||||
uwsgi_log("UNO\n");
|
||||
Py_INCREF(Py_None);
|
||||
uwsgi_log("UNO.0\n");
|
||||
if (PyDict_SetItemString(up.embedded_dict, "unbit", &_Py_NoneStruct)) {
|
||||
uwsgi_log("DUE\n");
|
||||
if (PyDict_SetItemString(up.embedded_dict, "unbit", Py_None)) {
|
||||
#endif
|
||||
PyErr_Print();
|
||||
exit(1);
|
||||
|
||||
@@ -99,12 +99,15 @@ PyObject *python_call(PyObject *callable, PyObject *args, int catch, struct wsgi
|
||||
|
||||
//uwsgi_log("ready to call %p %p\n", callable, args);
|
||||
|
||||
Py_INCREF(args);
|
||||
|
||||
pyret = PyEval_CallObject(callable, args);
|
||||
|
||||
//uwsgi_log("called\n");
|
||||
|
||||
if (PyErr_Occurred()) {
|
||||
|
||||
|
||||
#ifndef UWSGI_PYPY
|
||||
int do_exit = uwsgi_python_manage_exceptions();
|
||||
#else
|
||||
|
||||
@@ -28,7 +28,7 @@ void *uwsgi_request_subhandler_wsgi(struct wsgi_request *wsgi_req, struct uwsgi_
|
||||
#endif
|
||||
PyDict_SetItem(wsgi_req->async_environ, pydictkey, pydictvalue);
|
||||
Py_DECREF(pydictkey);
|
||||
Py_DECREF(pydictvalue);
|
||||
Py_DECREF(pydictvalue);
|
||||
}
|
||||
|
||||
if (wsgi_req->uh.modifier1 == UWSGI_MODIFIER_MANAGE_PATH_INFO) {
|
||||
@@ -48,13 +48,16 @@ void *uwsgi_request_subhandler_wsgi(struct wsgi_request *wsgi_req, struct uwsgi_
|
||||
}
|
||||
|
||||
|
||||
#ifndef UWSGI_PYPY
|
||||
// if async_post is mapped as a file, directly use it as wsgi.input
|
||||
if (wsgi_req->async_post) {
|
||||
#ifdef UWSGI_PYPY
|
||||
uwsgi_log("wsgi.input mapped to a file is not supported under PyPy\n");
|
||||
#else
|
||||
#ifdef PYTHREE
|
||||
wsgi_req->async_input = PyFile_FromFd(fileno(wsgi_req->async_post), "wsgi_input", "rb", 0, NULL, NULL, NULL, 0);
|
||||
#else
|
||||
wsgi_req->async_input = PyFile_FromFile(wsgi_req->async_post, "wsgi_input", "r", NULL);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
@@ -69,7 +72,6 @@ void *uwsgi_request_subhandler_wsgi(struct wsgi_request *wsgi_req, struct uwsgi_
|
||||
|
||||
|
||||
PyDict_SetItemString(wsgi_req->async_environ, "wsgi.input", wsgi_req->async_input);
|
||||
#endif
|
||||
|
||||
#ifdef UWSGI_SENDFILE
|
||||
PyDict_SetItemString(wsgi_req->async_environ, "wsgi.file_wrapper", wi->sendfile);
|
||||
@@ -108,6 +110,8 @@ void *uwsgi_request_subhandler_wsgi(struct wsgi_request *wsgi_req, struct uwsgi_
|
||||
PyDict_SetItemString(wsgi_req->async_environ, "wsgi.multiprocess", Py_True);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
if (wsgi_req->scheme_len > 0) {
|
||||
zero = UWSGI_PYFROMSTRINGSIZE(wsgi_req->scheme, wsgi_req->scheme_len);
|
||||
}
|
||||
@@ -124,6 +128,7 @@ void *uwsgi_request_subhandler_wsgi(struct wsgi_request *wsgi_req, struct uwsgi_
|
||||
}
|
||||
PyDict_SetItemString(wsgi_req->async_environ, "wsgi.url_scheme", zero);
|
||||
Py_DECREF(zero);
|
||||
*/
|
||||
|
||||
|
||||
wsgi_req->async_app = wi->callable;
|
||||
@@ -220,6 +225,7 @@ int uwsgi_response_subhandler_wsgi(struct wsgi_request *wsgi_req) {
|
||||
|
||||
pychunk = PyIter_Next(wsgi_req->async_placeholder);
|
||||
|
||||
|
||||
if (!pychunk) {
|
||||
if (PyErr_Occurred()) {
|
||||
#ifndef UWSGI_PYPY
|
||||
|
||||
Reference in New Issue
Block a user