Esempio n. 1
0
    def activate(self, session, description):
        limit = self.activation_limit
        if limit is not None and self.activations > limit:
            return

        task = ScheduledTask.spawn(self, parameters={"event": description})
        session.add(task)

        self.activations += 1
        self.activated = current_timestamp()
        return task
Esempio n. 2
0
    def activate(self, session, description):
        limit = self.activation_limit
        if limit is not None and self.activations > limit:
            return

        task = ScheduledTask.spawn(self, parameters={'event': description})
        session.add(task)

        self.activations += 1
        self.activated = current_timestamp()
        return task
Esempio n. 3
0
    def reschedule(self, session, occurrence=None):
        from platoon.models.scheduledtask import ScheduledTask
        if self.status != 'active':
            return
        if occurrence is None:
            occurrence = current_timestamp()

        query = session.query(ScheduledTask).filter_by(status='pending', parent_id=self.id)
        if query.count() > 0:
            return

        occurrence = self.schedule.next(occurrence)
        task = ScheduledTask.spawn(self, occurrence, parent_id=self.id)

        session.add(task)
        return task
Esempio n. 4
0
    def reschedule(self, session, occurrence=None):
        from platoon.models.scheduledtask import ScheduledTask
        if self.status != 'active':
            return
        if occurrence is None:
            occurrence = current_timestamp()

        query = session.query(ScheduledTask).filter_by(status='pending',
                                                       parent_id=self.id)
        if query.count() > 0:
            return

        occurrence = self.schedule.next(occurrence)
        task = ScheduledTask.spawn(self, occurrence, parent_id=self.id)

        session.add(task)
        return task