Can signal.alarm be safely cleared in python?
Pedro Franco de Carvalho
reddopp at gmail.com
Thu Nov 17 14:36:24 EST 2016
Assume a python program sets a handler function for the
`signal.SIGALRM` signal, and then schedules an alarm in T seconds with
`signal.alarm(T)`.
Assume the program later cancels any scheduled alarm with `signal.alarm(0)`.
Can the program safely assume that after the call to `signal.alarm(0)`
completes no alarm handling function will be called?
The reason I ask is that the signal module documentation [1] says that:
"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)."
Since this "later point" is not specified, could it be that a the
alarm is triggered and calls the low-level C handler shortly before
the call to `signal.alarm(0)`, but the python signal handler is only
executed at some point after this call?
[1]: https://docs.python.org/3.6/library/signal.html#execution-of-python-signal-handlers)
More information about the Python-list
mailing list