[issue6721] Locks in python standard library should be sanitized on fork

Tomaž Šolc report at bugs.python.org
Thu Jun 30 17:04:08 CEST 2011


Tomaž Šolc <tomaz.solc at tablix.org> added the comment:

> You mean a runtime warning? That would be ugly and clumsy.
> A warning is probably a good idea, but it should be added somewhere in
os.fork() and threading documentation.

I was thinking about a run time warning that is emitted if you call os.fork() while multiple threads are active. It is ugly, but at least it tells you you are doing something that will in most cases not work correctly. I certainly agree that a warning should also be added to os.fork() documentation.

I'm attaching an example patch that adds it into _after_fork() in threading.py, but there are a number of other places where it might go instead. 

I believe that the comp.programming.threads post from David Butenhof linked above explains why adding atfork() handlers isn't going to solve this.

----------
Added file: http://bugs.python.org/file22525/emit_warning_on_fork.patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue6721>
_______________________________________


More information about the Python-bugs-list mailing list