[mod_python] PyThreadState_Delete: tstate is still current

Peter Sanchez petersanchez at gmail.com
Wed Oct 12 13:25:35 EDT 2005


Sounds good and thanks! I look forward to the results!

Peter

On 10/12/05, Gregory (Grisha) Trubetskoy <grisha at modpython.org> wrote:
>
>
> You may be onto something here... I'll see about testing this out on my
> FreeBSD system.
>
> Grisha
>
> On Tue, 11 Oct 2005, Graham Dumpleton wrote:
>
> > Making an educated guess (???), in src/mod_python.c, can you modify the
> > release_interpreter() function and change:
> >
> > static void release_interpreter(void)
> > {
> > PyThreadState *tstate = PyThreadState_Get();
> > #ifdef WITH_THREAD
> > PyEval_ReleaseThread(tstate);
> > #endif
> > PyThreadState_Delete(tstate);
> > }
> >
> > to:
> >
> > static void release_interpreter(void)
> > {
> > PyThreadState *tstate = PyThreadState_Get();
> > #ifdef WITH_THREAD
> > PyEval_ReleaseThread(tstate);
> > #else
> > PyThreadState_Swap(NULL);
> > #endif
> > PyThreadState_Delete(tstate);
> > }
> >
> > The original doesn't seem quite right to me because it wouldn't revert
> > the thread state before deleting it when threads aren't used. There is a
> > similar bit of code in get_interpreter() where it has:
> >
> > if (!idata->obcallback)
> > {
> > #ifdef WITH_THREAD
> > PyEval_ReleaseThread(tstate);
> > #endif PyThreadState_Delete(tstate);
> >
>