python: Is there a downside to using faulthandler? python: Is there a downside to using faulthandler? python-3.x python-3.x

python: Is there a downside to using faulthandler?


This feature is very useful. Is there any particular reason it isn't enabled by default? Does it have any negative effects on performance?

The reason is that faulthandler remembers the file descriptor of stderr, usually fd 2. The problem is that fd 2 may become something else, like a socket, a pipe, an important file, etc. There is no reliable way to detect this situation, and so it's safer to not enable faulthandler by default in Python.

faulthandler is safe in almost all cases, except when a file descriptor stored by faulthandler is replaced. Problem also described in the doc:https://docs.python.org/dev/library/faulthandler.html#issue-with-file-descriptors

Note: I wrote faulthandler.