self.assertEqual(len(active), 2) self.assertEqual(active[0]["name"], tasks.sleeptask.name) self.assertEqual(active[0]["args"], [sleep]) def test_dump_reserved(self, sleep=1): r1 = tasks.sleeptask.delay(sleep) r2 = tasks.sleeptask.delay(sleep) r3 = tasks.sleeptask.delay(sleep) r4 = tasks.sleeptask.delay(sleep) self.ensure_accepted(r1.id) reserved = self.inspect().reserved(safe=True) self.assertTrue(reserved) reserved = reserved[self.worker.hostname] self.assertEqual(reserved[0]["name"], tasks.sleeptask.name) self.assertEqual(reserved[0]["args"], [sleep]) def test_dump_schedule(self, countdown=1): r1 = tasks.add.apply_async((2, 2), countdown=countdown) r2 = tasks.add.apply_async((2, 2), countdown=countdown) self.ensure_scheduled(r1.id, interval=0.1) schedule = self.inspect().scheduled(safe=True) self.assertTrue(schedule) schedule = schedule[self.worker.hostname] self.assertTrue(len(schedule), 2) self.assertEqual(schedule[0]["request"]["name"], tasks.add.name) self.assertEqual(schedule[0]["request"]["args"], [2, 2]) if __name__ == "__main__": unittest.main()
self.app.conf.BROKER_POOL_LIMIT = None try: self.app._pool = None self.assertFreed(its, task1.delay) finally: self.app.conf.BROKER_POOL_LIMIT = pool_limit def test_task_apply_leak_with_pool(self): its = QUICKTEST and 10 or 1000 self.assertNotEqual(self.app.conf.BROKER_BACKEND, "memory") @self.app.task def task2(): pass try: pool_limit = self.app.conf.BROKER_POOL_LIMIT except AttributeError: raise SkipTest("This version does not support autopool") self.app.conf.BROKER_POOL_LIMIT = 10 try: self.app._pool = None self.assertFreed(its, task2.delay) finally: self.app.conf.BROKER_POOL_LIMIT = pool_limit if __name__ == "__main__": unittest.main()