You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The documentation for signal.signal points out that the current annotation might be wrong (emphasis my own):
The handler is called with two arguments: the signal number and the current stack frame (None or a frame object; for a description of frame objects, see the description in the type hierarchy or see the attribute descriptions in the inspect module).
And when we use them, we can see that the signal number is passed as an int, not a signal.Signals member:
importsignaldefhandler(signal_number, frame):
print("In signal handler!")
print("Signal number:", signal_number, type(signal_number))
print("Stack frame: ", frame, type(frame))
# Set signal handler:signal.signal(signal.SIGHUP, handler)
# Use it:signal.raise_signal(signal.SIGHUP)
Which prints:
In signal handler!
Signal number: 1 <class 'int'>
Stack frame: <frame at 0x7f804402abe0, file '<stdin>', line 12, code <module>> <class 'frame'>
The text was updated successfully, but these errors were encountered:
In
signal.pyi:83
, signal handlers are typed as:But I think this might be more accurate:
The documentation for
signal.signal
points out that the current annotation might be wrong (emphasis my own):And when we use them, we can see that the signal number is passed as an
int
, not asignal.Signals
member:Which prints:
The text was updated successfully, but these errors were encountered: