[tasks] Ensure total number of seconds is not less than 0.
This commit is contained in:
parent
10bc939348
commit
4513dac7a3
@ -40,7 +40,11 @@ class Loop:
|
|||||||
|
|
||||||
self._sleep = sleep = self.seconds + (self.minutes * 60.0) + (self.hours * 3600.0)
|
self._sleep = sleep = self.seconds + (self.minutes * 60.0) + (self.hours * 3600.0)
|
||||||
if sleep >= MAX_ASYNCIO_SECONDS:
|
if sleep >= MAX_ASYNCIO_SECONDS:
|
||||||
raise ValueError('Total time exceeds asyncio imposed limit of {0} seconds.'.format(MAX_ASYNCIO_SECONDS))
|
fmt = 'Total number of seconds exceeds asyncio imposed limit of {0} seconds.'
|
||||||
|
raise ValueError(fmt.format(MAX_ASYNCIO_SECONDS))
|
||||||
|
|
||||||
|
if sleep < 0:
|
||||||
|
raise ValueError('Total number of seconds cannot be less than zero.')
|
||||||
|
|
||||||
if not inspect.iscoroutinefunction(self.coro):
|
if not inspect.iscoroutinefunction(self.coro):
|
||||||
raise TypeError('Expected coroutine function, not {0!r}.'.format(type(self.coro)))
|
raise TypeError('Expected coroutine function, not {0!r}.'.format(type(self.coro)))
|
||||||
@ -74,7 +78,6 @@ class Loop:
|
|||||||
""":class:`int`: The current iteration of the loop."""
|
""":class:`int`: The current iteration of the loop."""
|
||||||
return self._current_loop
|
return self._current_loop
|
||||||
|
|
||||||
|
|
||||||
def start(self, *args, **kwargs):
|
def start(self, *args, **kwargs):
|
||||||
r"""Starts the internal task in the event loop.
|
r"""Starts the internal task in the event loop.
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user