def process(self): try: session = self._db.get_session() self.logger.debug('Session was obtained from the database. - session=%s' % session) self._m_jg = jobgroup_findbyid(session, self._jobgroup_id, self._cf['env.uniqkey']) if self._m_jg is None: return False jobgroup_update(session, self._m_jg, JOBGROUP_STATUS['RUN']) # JobGroup UPDATE _m_jobs = job_findbyjobgroup_id(session, self._jobgroup_id, False) # order asc # action ret = False err = False try: ret = self._action(session, _m_jobs) except Exception, e: t_logger = logging.getLogger('pysilhouette_traceback') t_logger.info(traceback.format_exc()) self.logger.info('%s, Failed to perform the job action. Exceptions are not expected. - jobgroup_id=%d : %s, JobGroup status=%s' % (self.getName(), self._jobgroup_id, str(e.args), JOBGROUP_STATUS['APPERR'])) jobgroup_update(session, self._m_jg, JOBGROUP_STATUS['APPERR']) err = True try: if err is False: if ret is True: # normal jobgroup_update(session, self._m_jg, JOBGROUP_STATUS['OK']) else: # rollback jobgroup_update(session, self._m_jg, JOBGROUP_STATUS['NG']) # JobGroup UPDATE try: self._rollback(session, _m_jobs) except Exception, e: self.logger.info('Failed to perform a rollback. Exceptions are not expected. - jobgroup_id=%d : %s' % (self._jobgroup_id, str(e.args))) t_logger = logging.getLogger('pysilhouette_traceback') t_logger.info(traceback.format_exc()) finally: # finish try: self._finish() except Exception, e: self.logger.info('Failed to perform the finish action. Exceptions are not expected. - jobgroup_id=%d : %s' % (self._jobgroup_id, str(e.args))) t_logger = logging.getLogger('pysilhouette_traceback') t_logger.info(traceback.format_exc())
def run(self): self.logger = logging.getLogger('pysilhouette.worker.threadworker') try: self.process() except Exception, e: self.logger.error('%s - JobGroup execute failed. - jobgroup_id=%d : %s, JobGroup status=%s' \ % (self.getName(), self._jobgroup_id, str(e.args), JOBGROUP_STATUS['APPERR'])) t_logger = logging.getLogger('pysilhouette_traceback') t_logger.error(traceback.format_exc()) try: session = self._db.get_session() jobgroup_update(session, jobgroup_findbyid(session, self._jobgroup_id, self._cf['env.uniqkey']), JOBGROUP_STATUS['APPERR']) session.close() except: self.logger.error('JobGroup failed to update. - jobgroup_id=%d : %s, update status=%s' \ % (self._jobgroup_id, str(e.args), JOBGROUP_STATUS['APPERR'])) t_logger.error(traceback.format_exc())
def run(self): self.logger = logging.getLogger('pysilhouette.worker.threadworker') try: self.process() except Exception, e: self.logger.error('%s - JobGroup execute failed. - jobgroup_id=%d : %s, JobGroup status=%s' \ % (self.getName(), self._jobgroup_id, str(e.args), JOBGROUP_STATUS['APPERR'])) t_logger = logging.getLogger('pysilhouette_traceback') t_logger.error(traceback.format_exc()) try: session = self._db.get_session() jobgroup_update( session, jobgroup_findbyid(session, self._jobgroup_id, self._cf['env.uniqkey']), JOBGROUP_STATUS['APPERR']) session.close() except: self.logger.error('JobGroup failed to update. - jobgroup_id=%d : %s, update status=%s' \ % (self._jobgroup_id, str(e.args), JOBGROUP_STATUS['APPERR'])) t_logger.error(traceback.format_exc())
def process(self): try: session = self._db.get_session() self.logger.debug( 'Session was obtained from the database. - session=%s' % session) self._m_jg = jobgroup_findbyid(session, self._jobgroup_id, self._cf['env.uniqkey']) if self._m_jg is None: return False jobgroup_update(session, self._m_jg, JOBGROUP_STATUS['RUN']) # JobGroup UPDATE _m_jobs = job_findbyjobgroup_id(session, self._jobgroup_id, False) # order asc # action ret = False err = False try: ret = self._action(session, _m_jobs) except Exception, e: t_logger = logging.getLogger('pysilhouette_traceback') t_logger.info(traceback.format_exc()) self.logger.info( '%s, Failed to perform the job action. Exceptions are not expected. - jobgroup_id=%d : %s, JobGroup status=%s' % (self.getName(), self._jobgroup_id, str( e.args), JOBGROUP_STATUS['APPERR'])) jobgroup_update(session, self._m_jg, JOBGROUP_STATUS['APPERR']) err = True try: if err is False: if ret is True: # normal jobgroup_update(session, self._m_jg, JOBGROUP_STATUS['OK']) else: # rollback jobgroup_update( session, self._m_jg, JOBGROUP_STATUS['NG']) # JobGroup UPDATE try: self._rollback(session, _m_jobs) except Exception, e: self.logger.info( 'Failed to perform a rollback. Exceptions are not expected. - jobgroup_id=%d : %s' % (self._jobgroup_id, str(e.args))) t_logger = logging.getLogger( 'pysilhouette_traceback') t_logger.info(traceback.format_exc()) finally: # finish try: self._finish() except Exception, e: self.logger.info( 'Failed to perform the finish action. Exceptions are not expected. - jobgroup_id=%d : %s' % (self._jobgroup_id, str(e.args))) t_logger = logging.getLogger('pysilhouette_traceback') t_logger.info(traceback.format_exc())