Allow timedelta specifications in add_timeout #329

Closed
wants to merge 1 commit into
from

2 participants

@rbu
rbu commented Aug 4, 2011

The timedelta API makes this easier to use (and test).

@bdarnell
tornadoweb member

Good idea. I had thought about doing something like this if the number passed in was in the distant past, but it always felt ugly to have some magic number at which everything changed. Using timedelta objects makes it unambiguous. I've committed a slightly different version of this to use the total_seconds() method instead of converting it to seconds by hand. I also considered adding support for datetime objects for completeness, but converting datetime to timestamps is a pain so I'm leaving it out for now.

@bdarnell bdarnell added a commit that closed this pull request Aug 6, 2011
@bdarnell bdarnell Accept timedelta objects in IOLoop.add_timeout.
Closes #329.
688d59d
@bdarnell bdarnell closed this in 688d59d Aug 6, 2011
@rbu

total_seconds was introduced in Python 2.7, is this version limitation intented?
http://docs.python.org/library/datetime.html#datetime.timedelta.total_seconds

@bdarnell
tornadoweb member

No, it's not intentional. I'll change it to compute the total manually.

@rbu

Just for reference, this was fixed in 6b7ddc9

@schlamar schlamar referenced this pull request May 9, 2014
Closed

Improve API for timeouts #1049

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment