def _handleModelRunnerException(jobID, modelID, jobsDAO, experimentDir, logger, e):
 msg = StringIO.StringIO()
 print >>msg, ('Exception occurred while running model %s: %r (%s)' % (modelID, e, type(e)))
 traceback.print_exc(None, msg)
 completionReason = jobsDAO.CMPL_REASON_ERROR
 completionMsg = msg.getvalue()
 logger.error(completionMsg)
 if (type(e) is not InvalidConnectionException):
  jobsDAO.modelUpdateResults(modelID, results=None, numRecords=0)
 if (type(e) == JobFailException):
  workerCmpReason = jobsDAO.jobGetFields(jobID, ['workerCompletionReason'])[0]
  if (workerCmpReason == ClientJobsDAO.CMPL_REASON_SUCCESS):
   jobsDAO.jobSetFields(jobID, fields=dict(cancel=True, workerCompletionReason=ClientJobsDAO.CMPL_REASON_ERROR, workerCompletionMsg=': '.join((str(i) for i in e.args))), useConnectionID=False, ignoreUnchanged=True)
 return (completionReason, completionMsg)

def _handleModelRunnerException ( jobID , modelID , jobsDAO , experimentDir , logger , e ) : msg = StringIO . StringIO ( ) print >> msg , ( 'Exception occurred while running model %s: %r (%s)' % ( modelID , e , type ( e ) ) ) traceback . print_exc ( None , msg ) completionReason = jobsDAO . CMPL_REASON_ERROR completionMsg = msg . getvalue ( ) logger . error ( completionMsg ) if ( type ( e ) is not InvalidConnectionException ) : jobsDAO . modelUpdateResults ( modelID , results = None , numRecords = 0 ) if ( type ( e ) == JobFailException ) : workerCmpReason = jobsDAO . jobGetFields ( jobID , [ 'workerCompletionReason' ] ) [ 0 ] if ( workerCmpReason == ClientJobsDAO . CMPL_REASON_SUCCESS ) : jobsDAO . jobSetFields ( jobID , fields = dict ( cancel = True , workerCompletionReason = ClientJobsDAO . CMPL_REASON_ERROR , workerCompletionMsg = ': ' . join ( ( str ( i ) for i in e . args ) ) ) , useConnectionID = False , ignoreUnchanged = True ) return ( completionReason , completionMsg )
perform standard handling of an exception that occurs while running a model .