By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,813 Members | 1,130 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,813 IT Pros & Developers. It's quick & easy.

callback cashing python

P: n/a

i have a multithreaded c server that calls process_method in a different
c thread per each call. process_method calls a python function bar in
module foo. function bar calls back into c. i've removed all the type
error handling and simplified the code to hopefully show a minimum
amount of code. when only one request is hitting the server at a time
this works correctly even at fast speeds. but as soon as a second
request is made concurrently, the python24.dll will crash and
session.callback() in the python code never returns. i've tried
wrapping the callback code in PyGILState_Ensure(), PyEval_SaveThread()
without success.

does anyone know what i have to do to the c callback to prevent python
from crashing?


static void process_method(session *session)
PyObject *py_obj_session = NULL;
PyObject *py_mod_foo = NULL;
PyObject *py_call_bar = NULL;
PyThreadState *py_interp = NULL;

py_interp = get_py_interpreter(session);
py_obj_session = get_py_session(session);

py_mod_foo = PyImport_ImportModule("foo");
py_call_bar = PyObject_GetAttrString(py_mod_foo, "bar");
PyObject_CallFunctionObjArgs(py_call_bar, py_obj_session, NULL);


# module bar

def bar(session):

/* session.callback() /*
static PyObject* callback(PyObject *self, PyObject *args)
return Py_None;

Oct 18 '06 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.