Example #1
0
 def test_task_infinite(self):
     d = dict(counter = 0)
     t = Task(target=self.__test_counter, infinite=True)
     t.args = (d,)
     t = self.tp.run(t)
     time.sleep(0.01)
     t.stop()
     self.assertGreater(d['counter'], 2)
Example #2
0
 def test_task(self):
     task = Task(target=lambda x: x)
     self.assertIsInstance(task.id, long)
     self.assertEqual(task.target(True), True)
     self.assertEqual(task.success(True), True)
     self.assertEqual(task.failure(False), False)
     self.assertIsInstance(task.args, tuple)
     self.assertIsInstance(task.kwargs, dict)
Example #3
0
 def test_task_failure(self):
     t = Task(target=self.__test_failure, failure=self._catch_fail)
     self.tp.run(t)
Example #4
0
 def test_tp_stress(self):
     for x in range(5000):
         t = Task(target=self.__test_target)
         t.args = ("task" + str(x),)
         t = self.tp.run(t)
Example #5
0
 def test_worker_task(self):
     t = Task(target=self.__test_target, success=self._test_cb)
     t.args = ("task1",)
     t = self.tp.run(t)
     retval = self.tp_results.get(timeout=5)
     self.assertEqual(retval, "task1test")