From 576a1e7cb27d8d432ce636f1d931fb0e2b41da0c Mon Sep 17 00:00:00 2001 From: "roberto@debian32" Date: Sat, 25 Jun 2011 07:44:21 +0200 Subject: [PATCH] fixed threadstate swap --- plugins/python/python_plugin.c | 6 ++++-- plugins/python/pyutils.c | 4 ++++ plugins/python/uwsgi_pymodule.c | 3 +-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/plugins/python/python_plugin.c b/plugins/python/python_plugin.c index a3cf4c06..d05f35be 100644 --- a/plugins/python/python_plugin.c +++ b/plugins/python/python_plugin.c @@ -859,8 +859,10 @@ void uwsgi_python_enable_threads() { up.gil_get = gil_real_get; up.gil_release = gil_real_release; - up.swap_ts = threaded_swap_ts; - up.reset_ts = threaded_reset_ts; + if (uwsgi.threads > 1) { + up.swap_ts = threaded_swap_ts; + up.reset_ts = threaded_reset_ts; + } uwsgi_log("threads support enabled\n"); } diff --git a/plugins/python/pyutils.c b/plugins/python/pyutils.c index 9a8ff1e7..0491309e 100644 --- a/plugins/python/pyutils.c +++ b/plugins/python/pyutils.c @@ -12,8 +12,12 @@ PyObject *python_call(PyObject *callable, PyObject *args, int catch) { PyObject *pyret; + uwsgi_log("ready to call %p %p\n", callable, args); + pyret = PyEval_CallObject(callable, args); + uwsgi_log("called\n"); + if (PyErr_Occurred()) { if (PyErr_ExceptionMatches(PyExc_MemoryError)) { uwsgi_log("Memory Error detected !!!\n"); diff --git a/plugins/python/uwsgi_pymodule.c b/plugins/python/uwsgi_pymodule.c index 46165ff2..5e1b07a8 100644 --- a/plugins/python/uwsgi_pymodule.c +++ b/plugins/python/uwsgi_pymodule.c @@ -436,8 +436,7 @@ PyObject *py_uwsgi_register_rpc(PyObject * self, PyObject * args) { if (uwsgi_register_rpc(name, 0, argc, func)) { - Py_INCREF(Py_None); - return Py_None; + return PyErr_Format(PyExc_ValueError, "unable to register rpc function"); } Py_INCREF(Py_True);