bpo-30807: signal.setitimer() now uses _PyTime API#3865
bpo-30807: signal.setitimer() now uses _PyTime API#3865vstinner merged 3 commits intopython:masterfrom vstinner:setitimer_pytime
Conversation
The _PyTime API handles detects overflow and is well tested.
Modules/clinic/signalmodule.c.h
Outdated
|
|
||
| PyDoc_STRVAR(signal_setitimer__doc__, | ||
| "setitimer($module, which, seconds, interval=0.0, /)\n" | ||
| "setitimer($module, which, seconds, interval=None, /)\n" |
There was a problem hiding this comment.
I don't see any point in changing the default to None.
There was a problem hiding this comment.
Oops, it wasn't my intent. I fixed it.
Document that the signal will only be sent once if internal is equal to zero.
Doc/library/signal.rst
Outdated
| :const:`signal.ITIMER_VIRTUAL` sends :const:`SIGVTALRM`, | ||
| and :const:`signal.ITIMER_PROF` will deliver :const:`SIGPROF`. | ||
|
|
||
| If *interval* is equal to zero, the signal will only be sent once. |
There was a problem hiding this comment.
I'm not sure that it's correct to promise that the signal will be sent. If seconds is in the past (using ITIMER_REAL), the signal is never sent, no?
Maybe I should replace "and after that every interval seconds" with "and after that every interval seconds (if interval is not equal to zero)" instead? What do you think @pitrou?
There was a problem hiding this comment.
According to POSIX, setitimer should return EINVAL when a negative argument is passed.
There was a problem hiding this comment.
>>> signal.setitimer(signal.ITIMER_REAL, 0, -1)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
signal.ItimerError: [Errno 22] Invalid argument
>>> signal.setitimer(signal.ITIMER_REAL, -1, 0)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
signal.ItimerError: [Errno 22] Invalid argumentThere was a problem hiding this comment.
I'm not sure that I understand correctly your comments. Do you mean that setitimer() warrants that at least one signal will be fired?
I changed the documentation to not overspecify Python since Python is just a thin wrapper to the system setitimer() function. I just added "(if interval is non-zero)" to the existing doc.
The _PyTime API handles detects overflow and is well tested.
https://bugs.python.org/issue30807