Esempio n. 1
0
    def next(or_upcoming=False):
        q = Session.query(Task).filter_by(state='pending')
        if not or_upcoming:
            q = q.filter(Task.time_wait_until<=datetime.now())

        q = q.order_by(Task.time_wait_until.asc())
        return q.first()
Esempio n. 2
0
 def delay_resource_group(resource_group, delta=None):
     # Make sure all tasks of given resource_group are scheduled for no sooner than now+delta.
     affected_tasks = Session.query(Task).filter(and_(Task.time_wait_until > (datetime.now() - delta), Task.state<'completed', Task.resource_group==resource_group))
     for t in affected_tasks:
         t.time_wait_until += delta