示例#1
0
文件: process.py 项目: siq/platoon
 def _schedule_task(self, session, action, delta=None, limit=0, timeout=120, backoff=1.4):
     self.tasks[action] = ScheduledTask.create(session,
         tag='%s:%s' % (action, self.tag),
         action=ProcessAction(process_id=self.id, action=action),
         delta=delta,
         retry_limit=limit,
         retry_timeout=timeout,
         retry_backoff=backoff)
示例#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
示例#3
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
示例#4
0
 def _schedule_task(self,
                    session,
                    action,
                    delta=None,
                    limit=0,
                    timeout=120,
                    backoff=1.4):
     self.tasks[action] = ScheduledTask.create(
         session,
         tag='%s:%s' % (action, self.tag),
         action=ProcessAction(process_id=self.id, action=action),
         delta=delta,
         retry_limit=limit,
         retry_timeout=timeout,
         retry_backoff=backoff)
示例#5
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
示例#6
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