diff --git a/mo/jobs/__init__.py b/mo/jobs/__init__.py index 6bff1ee02473c66b5d077eb9fd56271dfefd667b..71fd12966ebae07d2192cfeab29bebcabf1b25b2 100644 --- a/mo/jobs/__init__.py +++ b/mo/jobs/__init__.py @@ -147,7 +147,11 @@ class TheJob: _handler_table[job.type](self) if self.errors: logger.info(f'Job: Neúspěšně dokončen job #{job.job_id} ({job.result})') - job.state = db.JobState.failed + if job.user_id == 0: + # Joby běžící na systémového uživatele produkují interní chyby + job.state = db.JobState.internal_error + else: + job.state = db.JobState.failed job.out_json = {'errors': self.errors} if job.result == "": job.result = 'Došlo k chybám, viz detail' @@ -156,11 +160,12 @@ class TheJob: job.state = db.JobState.done except Exception as e: logger.error(f'Job: Chyba při zpracování jobu #{job.job_id}: %s', e, exc_info=e) - job.state = db.JobState.failed + job.state = db.JobState.internal_error job.result = 'Interní chyba, informujte prosím správce systému.' job.finished_at = mo.util.get_now() - job.expires_at = job.finished_at + timedelta(minutes=self.expires_in_minutes) + if job.state != db.JobState.internal_error: + job.expires_at = job.finished_at + timedelta(minutes=self.expires_in_minutes) sess.commit()