[Python-Dev] test_fork1 on SMP? (was Re: [Python Dev] test_fork1 failing --with-threads (for some people)...)

Guido van Rossum guido@beopen.com
Wed, 09 Aug 2000 17:43:35 -0500


> If I add Py_BEGIN_ALLOW_THREADS and Py_END_ALLOW_THREADS around fork()
> in posixmodule then the child is the process which always seems to hang.

I first thought that the lock should be released around the fork too,
but later I realized that that was exactly wrong: if you release the
lock before you fork, another thread will likely grab the lock before
you fork; then in the child the lock is held by that other thread but
that thread doesn't exist, so when the main thread tries to get the
lock back it hangs in the Py_END_ALLOW_THREADS.

--Guido van Rossum (home page: http://www.pythonlabs.com/~guido/)