- def is_stale(self):
- if self.task is None:
- # Race; just let the other task roll.
- return False
- try:
- meta = TaskMeta.objects.get(task_id=self.task)
- assert meta.status in (u'PENDING', u'STARTED', u'SUCCESS', u'RETRY')
- except TaskMeta.DoesNotExist:
- # Might happen it's not yet there.
- pass
- except AssertionError:
- return True
- return False
+ @classmethod
+ def can_order(cls, path):
+ return (cls.objects.filter(path=path).exists() or
+ cls.exists(path) or
+ cls.objects.count() < WAITER_MAX_QUEUE
+ )