Added period check in PeriodicCallback

If a user currently passes in 0ms (hopefully by accident) as the
callback time for a periodic callback, Tornado consumes a huge amount
of CPU and never calls the function.
This commit is contained in:
Peter Sobot 2012-10-23 15:33:17 -03:00
parent db843a5987
commit 041388cbca
1 changed files with 2 additions and 0 deletions

View File

@ -679,6 +679,8 @@ class PeriodicCallback(object):
"""
def __init__(self, callback, callback_time, io_loop=None):
self.callback = callback
if callback_time == 0:
raise ValueError("Periodic callback cannot have a period of 0ms")
self.callback_time = callback_time
self.io_loop = io_loop or IOLoop.instance()
self._running = False