Beispiel #1
0
    def run(self, every=None, times=None, start_in=0):
        """
        Start running the task. Returns a future object.
        """
        every = get_seconds(every)
        start_in = get_seconds(start_in)
        every, times = self.__set_every_times_defaults(every, times)

        self.future = self.__executor.submit(
            _run_task, self.__fn, self.__id, every, times, start_in,
            self.__kwargs, self.__debug, self.__on_success_callback,
            self.__on_error_callback, self.__on_iter_callback,
            self.__on_finished_callback)

        return self.future
Beispiel #2
0
 def test_float(self):
     assert get_seconds(1.2) == 1.2
Beispiel #3
0
 def test_number(self):
     assert get_seconds(10) == 10
Beispiel #4
0
 def test_none(self):
     assert get_seconds(None) is None
Beispiel #5
0
 def test_days_string(self):
     assert get_seconds('10 days') == 864000
Beispiel #6
0
 def test_hours_string(self):
     assert get_seconds('10 hours') == 36000
Beispiel #7
0
 def test_minutes_string(self):
     assert get_seconds('10 minutes') == 600
Beispiel #8
0
 def test_seconds_string(self):
     assert get_seconds('10 seconds') == 10