Skip to content

Conversation

@vstinner
Copy link
Member

@vstinner vstinner commented Oct 3, 2017

The _PyTime API handles detects overflow and is well tested.

https://bugs.python.org/issue30807

The _PyTime API handles detects overflow and is well tested.

PyDoc_STRVAR(signal_setitimer__doc__,
"setitimer($module, which, seconds, interval=0.0, /)\n"
"setitimer($module, which, seconds, interval=None, /)\n"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see any point in changing the default to None.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, it wasn't my intent. I fixed it.

Document that the signal will only be sent once if internal is equal
to zero.
: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.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to POSIX, setitimer should return EINVAL when a negative argument is passed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

>>> 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 argument

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@vstinner vstinner merged commit ef611c9 into python:master Oct 13, 2017
@vstinner vstinner deleted the setitimer_pytime branch October 13, 2017 20:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants