Example #1
0
    def process_jobs(self, ch, method, properties, jobrecord):
        '''
        Work out dependancies and order
        '''
        # Create a Job instance from the job record
        job = Job().load(jobrecord)
        # Register the job with the dispatcher
        self._register_job(job)
        self.log.info('Registered job: {0}'.format(job.state.id))
        # Return registration success message to client
        _prop = pika.BasicProperties(correlation_id=properties.correlation_id)
        self.channel.basic_publish(exchange='',
                                   routing_key=properties.reply_to,
                                   properties=_prop,
                                   body=str(job.state.id))

        # Work out the first tasks to run
        self.log.debug('Decomposing job; calculating first tasks to run')
        tasks_to_run = job.get_next_tasks_to_run()
        #This was added to fill out any id args in tasks right at the beginning
        for task in tasks_to_run:
            if task.state.args is not None:
                task = job.update_task_args(task)
        for task in tasks_to_run:
            task.state.status = 'SUBMITTED'
            self.publish_task(task.state.save())
Example #2
0
    def process_jobs(self, ch, method, properties, jobrecord):
        '''
        Work out dependancies and order
        '''
        # Create a Job instance from the job record
        job = Job().load(jobrecord)
        # Register the job with the dispatcher
        #self._register_job(job)
        self._persist_job(job)
        self.log.info('Registered job: {0} in DB'.format(job.state.id))
        # Return registration success message to client
        _prop = pika.BasicProperties(correlation_id=properties.correlation_id)
        self.channel.basic_publish(exchange='',
                                   routing_key=properties.reply_to,
                                   properties=_prop,
                                   body=str(job.state.id))

        # Work out the first tasks to run
        self.log.debug('Decomposing job; calculating first tasks to run')
        tasks_to_run = job.get_next_tasks_to_run()
        #This was added to fill out any id args in tasks right at the beginning
        for task in tasks_to_run:
            if task.state.args is not None:
                task = job.update_task_args(task)
        for task in tasks_to_run:
            task.state.status = 'SUBMITTED'
            if not task.state.start_time:
                task.state.start_time = time.time()
            if task.state.timeout:
                self.log.debug("Task {0} timeout in {1}".format(task.state.id,str(task.state.timeout)))
                threading.Timer(task.state.timeout, self._caretaker).start()
            self.publish_task(task.state.save())
        #Now we've decided what to do with Job lets update the DB
        self.log.debug("Updating to DB job: {0}".format(job.state.id))
        self._update_job(job)
Example #3
0
    def process_jobs(self, ch, method, properties, jobrecord):
        '''
        Work out dependancies and order
        '''
        # Create a Job instance from the job record
        job = Job().load(jobrecord)
        # Register the job with the dispatcher
        self._register_job(job)
        self.log.info('Registered job: {0}'.format(job.state.id))
        # Return registration success message to client
        _prop = pika.BasicProperties(correlation_id=properties.correlation_id)
        self.channel.basic_publish(exchange='',
                                   routing_key=properties.reply_to,
                                   properties=_prop,
                                   body=str(job.state.id))

        # Work out the first tasks to run
        self.log.debug('Decomposing job; calculating first tasks to run')
        tasks_to_run = job.get_next_tasks_to_run()
        #This was added to fill out any id args in tasks right at the beginning
        for task in tasks_to_run:
            if task.state.args is not None:
                task = job.update_task_args(task)
        for task in tasks_to_run:
            task.state.status = 'SUBMITTED'
            self.publish_task(task.state.save())