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)
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
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
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)
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