Stéphane Bidoul
sbi at acse.be
Mon Jun 5 20:56:13 EST 2000
Hi again, I think I've got an explanation for the crashes under windows. Disclaimer: I'm no apache expert, nor am I intimate with python threading, so bear with me if the following is completely off-track. In the python doc, I've found the following: <PythonDocExcerpt> [...] when threads are created from C, they don't have the global interpreter lock, nor is there a thread state data structure for them. Such threads must bootstrap themselves into existence, by first creating a thread state data structure [PyThreadState_New()?], then acquiring the lock, and finally storing their thread state pointer, before they can start using the Python/C API. When they are done, they should reset the thread state pointer, release the lock, and finally free their thread state data structure. </PythonDocExcerpt> Now, in mod_python, threads are created by Apache, so they should somehow be bootstrapped for python. In my understanding, mod_python only initializes one thread per interpreter: the Apache thread that is happening to create the interpreter (using Py_NewInterpreter(), which in turns calls PyThreadState_New() for the interpreter's "main" thread). All other apache threads using that same interpreter will not call PyThreadState_New()... hence the potential conflict. To summarize, my understanding of the python doc is that there should be one PyThreadState_New() for each (apache thread, python interpreter) couple. AFAIK, threads are used only in the Windows version of Apache, so the problem should not occur on unix (athough that will change with Apache 2). Also, if ThreadsPerChild is set to 1, the problem disappears, which seems to confirm my diagnostic. Again, bear with me if this is totally wrong... If this is correct, however, I've no idea (yet) on how to fix it... What do you think? Can a python threading expert confirm or infirm this diagnostic? -Stephane sbi at acse.be
|