Python Glossary Русский

Python 3.3+Linux · macOSfaulthandlerfunction

faulthandler.unregister()

dump on signal

Removes the signal handler set by register(); returns True if there was one. Linux and macOS.

Syntax

faulthandler.unregister(signum)

It returns a bool instead of raising: unregister() on a signal that was never registered simply gives False — handy to check whether a handler existed. Remove it before closing the file passed to register(), otherwise a signal dump goes into whatever file received the same descriptor. The function does not exist on Windows.

Examples

import faulthandler, signal
print(faulthandler.unregister(signal.SIGUSR1))  # → False
with open('sig.txt', 'w') as f:
    faulthandler.register(signal.SIGUSR1, file=f)
    print(faulthandler.unregister(signal.SIGUSR1))  # → True

See also

Open in the full glossarydocs.python.orgReport an inaccuracy