Graham Dumpleton
grahamd at dscpl.com.au
Tue Mar 15 16:31:30 EST 2005
Thanks for going to all the effort, a lot of times when suggesting things on the mailing list, you simply never hear from people again, so you have no idea if what you suggested worked or not. See further suggestions below. On 16/03/2005, at 7:25 AM, Jamie Kirkpatrick wrote: >> At this point things get a bit trickier as one is dealing with the C >> code. >> It is worth noting though that most instances of where a 500 response >> are >> generated in the mod_python.c file are preceded by message logging. >> The >> only ones that aren't are all of the form: >> >> /* get/create interpreter */ >> idata = get_interpreter(interp_name, req->server); >> >> if (!idata) >> return HTTP_INTERNAL_SERVER_ERROR; >> >> Not being able to get/create the interpreter is pretty severe and if >> that >> was happening then no Python code at all would be getting executed. I >> am >> not sure why this situation couldn't be logged as well. Thus instead >> of >> that above, have: >> >> if (!idata) { >> ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, req, >> "python_handler: Can't get/create >> interpreter."); >> >> return HTTP_INTERNAL_SERVER_ERROR; >> } > > OK - so this does indeed seem to be the case. On a restart I get the > message logged: > > [Tue Mar 15 20:20:55 2005] [notice] Apache/2.0.53 (Unix) DAV/2 > mod_python/3.1.3 Python/2.4 configured -- resuming normal operations > [Tue Mar 15 20:20:59 2005] [error] [client 192.168.2.2] > python_handler: Can't get/create interpreter. Next thing to try would be to add logging inside the get_interpreter() function. Suggest logging the "name" input parameter supplied to the function, but more importantly log whether the "interpreters" global variable is actually set when the function is being called. Ie., if (!interpreters) { ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, req, "python_handler: interpreters dictionary not initialised."); return NULL; } There is a return near the end of the function as well which doesn't log anything which you could add something for as well. if (!idata->obcallback) { #ifdef WITH_THREAD PyEval_ReleaseThread(tstate); #endif PyThreadState_Delete(tstate); ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, req, "python_handler: no interpreter callback found."); return NULL; } When I get a chance I'll have a look at how "interpreters" gets set and what problems could result. Wander if my Mac OS X patch screws this up in some cases. Graham
|