Ronald Oussoren wrote:
Wouldn't this specific problem be fixed if os.fork were to acquire the import lock before calling fork(2)?
Right. Of course, you need to release the lock then both in the parent and the child. Also, all places that currently do PyOs_AfterFork should get modified (i.e. fork1, and forkpty also).