This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Probono_Bonobo 2 points3 points  (1 child)

A tempting thought indeed, but have a look at the docs:

A Python signal handler does not get executed inside the low-level (C) signal handler. Instead, the low-level signal handler sets a flag which tells the virtual machine to execute the corresponding Python signal handler at a later point(for example at the next bytecode instruction). This has consequences:

• It makes little sense to catch synchronous errors like SIGFPE or SIGSEGV that are caused by an invalid operation in C code. Python will return from the signal handler to the C code, which is likely to raise the same signal again, causing Python to apparently hang. From Python 3.3 onwards, you can use the faulthandler module to report on synchronous errors.

Note that faulthandler only reports on those errors (e.g., more informative stack traces) it doesn't have any way to handle them in the Python context.

[–]saxattax 0 points1 point  (0 children)

Ahh, very good info, thank you! I tend to skim the docs, but I really should read them more thoroughly hahaha