>> Instead, we should aim to make Python fork-safe. If the primary concern
>> is that locks get inherited, we should change the Python locks so that
>> they get auto-released on fork (unless otherwise specified on lock
>> creation). This may sound like an uphill battle, but if there was a
>> smart and easy solution to the problem, POSIX would be providing it.
>>
>> Regards,
>> Martin
> 
> Posix threads expose the _atfork function

Yes - that's a solution, but one that I would call neither smart nor
simple. It requires you to register all resources with atfork that you
want to see released.

I was puzzled as to how precisely use atfork, but the opengroup atfork
documentation actually explains it: you need to acquire all mutexes in
the prepare handler, and then release them in the parent and child
handlers. This, again, is tedious; ISTM it can also cause deadlocks if
the prepare handler acquires locks in the wrong order.

Regards,
Martin
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to