On Thu, May 18, 2006 at 3:02 PM, "Martin v. Löwis"email@example.com wrote:
Right. With some googling, I found that one solution is pthread_atexit: a pthread_atexit handler is a triple (before, in_parent, in_child). You set it to (acquire, release, release).
Did you mean pthread_atfork() ?
When somebody forks, the pthread library will first acquire the import lock in the thread that wants to fork. Then the fork occurs, and the import lock gets then released both in the parent and in the child.
I would like to see this approach implemented, but I agree with you that a test case should be created first.
Whould some new C-API functions do the trick?
PyOS_AtForkPrepare() # acquire import lock pid = fork() if (pid == 0) PyOS_AtForkChild() # current PyOS_AfterFork() + release import lock else PyOS_AtForkParent() # release import lock