Пример #1
0
    def process(self):
        self.logger.info('performer : [started]')
        while True:
            fp = open(self.cf["performer.mkfifo.path"], 'r')
            try:
                code = fp.read()
            finally:
                fp.close()
                
            #self.logger.info('Received code from the FIFO file. - code=%s' % code)
            session = self.db.get_session()
            m_jgs = jobgroup_findbytype_status(session, JOBGROUP_TYPE['SERIAL'])
            session.close()
            #self.logger.info('Queued the Job Group from the database. - Number of JobGroup=%d' % len(m_jgs))
            self.logger.info('Activity Information. - [fifo_code=%s, type=serial, jobgroup_num=%d]' % (code, len(m_jgs)))
            if code == self.cf["performer.mkfifo.start.code"]:
                if 0 < len(m_jgs):
                    for m_jg in m_jgs:
                        try:
                            w = SimpleWorker(self.cf, self.db, m_jg.id)
                            w.process()
                        except Exception, e:
                            self.logger.info('Failed to perform the job group. Exceptions are not expected. - jobgroup_id=%d : %s'
                                         % (m_jg.id, str(e.args)))
                            print >>sys.stderr, traceback.format_exc()
                            t_logger = logging.getLogger('pysilhouette_traceback')
                            t_logger.error(traceback.format_exc())

                            try:
                                session = self.db.get_session()
                                jobgroup_update(session, m_jg, JOBGROUP_STATUS['APPERR'])
                                session.close()
                            except:
                                logger.error('Failed to change the status of the job group. - jobgroup_id=%d : %s'
                                             % (m_jg.id, str(e.args)))
                                t_logger = logging.getLogger('pysilhouette_traceback')
                                t_logger.error(traceback.format_exc())

                else:
                    #self.logger.info('No Job Group.')
                    pass
            elif code == self.cf["performer.mkfifo.stop.code"]:
                self.logger.warning('Received stop code from the FIFO file. - code=%s' % code)
                return PROCSUCCESS
Пример #2
0
    import pysilhouette
    import pysilhouette.log
    import sys
    pysilhouette.log.reload_conf(pysilhouette.cf["env.sys.log.conf.path"])
    number = 50
    dummy_set_job(pysilhouette.cf,number,'echo "aaaaaa"','echo "bbbbb"','echo "cccc"','parallel')
    try:
        db = Database(pysilhouette.cf['database.url'],encoding="utf-8",convert_unicode=True,echo=True,echo_pool=True)
        reload_mappers(db.get_metadata())
        session = db.get_session()
    except Exception, e:
        print >>sys.stderr, 'Initializing a database error'
        raise

    from pysilhouette.db.access import jobgroup_findbytype_status
    m_jgs = jobgroup_findbytype_status(session, JOBGROUP_TYPE['PARALLEL'])
    for m_jg in m_jgs:
        try:
            tq.put(ThreadWorker(pysilhouette.cf, db, m_jg.id))
        except Exception, e:
            import traceback
            print traceback.format_exc()

    import time
    time.sleep(2)

    while True:
        size = tq.response_clean()
        print 'ret=' + str(size)
        if size <= 0:
            break