本文整理汇总了Python中the_tale.common.postponed_tasks.prototypes.PostponedTaskPrototype.remove_old_tasks方法的典型用法代码示例。如果您正苦于以下问题:Python PostponedTaskPrototype.remove_old_tasks方法的具体用法?Python PostponedTaskPrototype.remove_old_tasks怎么用?Python PostponedTaskPrototype.remove_old_tasks使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类the_tale.common.postponed_tasks.prototypes.PostponedTaskPrototype
的用法示例。
在下文中一共展示了PostponedTaskPrototype.remove_old_tasks方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: handle
# 需要导入模块: from the_tale.common.postponed_tasks.prototypes import PostponedTaskPrototype [as 别名]
# 或者: from the_tale.common.postponed_tasks.prototypes.PostponedTaskPrototype import remove_old_tasks [as 别名]
def handle(self, *args, **options):
from the_tale.common.postponed_tasks.prototypes import PostponedTaskPrototype
from the_tale.forum.prototypes import SubCategoryReadInfoPrototype, ThreadReadInfoPrototype
from the_tale.post_service.prototypes import MessagePrototype
PostponedTaskPrototype.remove_old_tasks()
ThreadReadInfoPrototype.remove_old_infos()
SubCategoryReadInfoPrototype.remove_old_infos()
MessagePrototype.remove_old_messages()
示例2: test_remove_old_tasks
# 需要导入模块: from the_tale.common.postponed_tasks.prototypes import PostponedTaskPrototype [as 别名]
# 或者: from the_tale.common.postponed_tasks.prototypes.PostponedTaskPrototype import remove_old_tasks [as 别名]
def test_remove_old_tasks(self):
task = PostponedTaskPrototype.create(FakePostponedInternalTask())
task.state = POSTPONED_TASK_STATE.PROCESSED
task.save()
removed_task = PostponedTaskPrototype.create(FakePostponedInternalTask())
removed_task.state = POSTPONED_TASK_STATE.ERROR
removed_task.save()
PostponedTaskPrototype.remove_old_tasks()
self.assertEqual(PostponedTask.objects.all().count(), 3)
with mock.patch('the_tale.common.postponed_tasks.conf.postponed_tasks_settings.TASK_LIVE_TIME', -1):
PostponedTaskPrototype.remove_old_tasks()
self.assertEqual(PostponedTask.objects.all().count(), 1)