diff --git a/server/.settings/org.eclipse.core.resources.prefs b/server/.settings/org.eclipse.core.resources.prefs index 7709640c..2f676d01 100644 --- a/server/.settings/org.eclipse.core.resources.prefs +++ b/server/.settings/org.eclipse.core.resources.prefs @@ -96,6 +96,7 @@ encoding//src/uds/dispatchers/test/urls.py=utf-8 encoding//src/uds/dispatchers/test/views.py=utf-8 encoding//src/uds/management/commands/config.py=utf-8 encoding//src/uds/management/commands/taskManager.py=utf-8 +encoding//src/uds/management/commands/taskManager_enterprise.py=utf-8 encoding//src/uds/migrations/0001_initial.py=utf-8 encoding//src/uds/migrations/0002_auto__del_unique_userpreference_name_module.py=utf-8 encoding//src/uds/migrations/0004_auto__add_field_deployedservice_state_date.py=utf-8 @@ -161,6 +162,7 @@ encoding//src/uds/transports/TSNX/__init__.py=utf-8 encoding//src/uds/transports/TSNX/web.py=utf-8 encoding//src/uds/transports/__init__.py=utf-8 encoding//src/uds/urls.py=utf-8 +encoding//src/uds/urls_enterprise.py=utf-8 encoding//src/uds/views.py=utf-8 encoding//src/uds/web/errors.py=utf-8 encoding//src/uds/web/forms/LoginForm.py=utf-8 diff --git a/server/src/uds/core/jobs/Scheduler.py b/server/src/uds/core/jobs/Scheduler.py index ebcbc1a3..60d2ee2d 100644 --- a/server/src/uds/core/jobs/Scheduler.py +++ b/server/src/uds/core/jobs/Scheduler.py @@ -48,22 +48,34 @@ class JobThread(threading.Thread): self._jobInstance = jobInstance self._dbJobId = dbJob.id - @transaction.commit_on_success def run(self): try: self._jobInstance.execute() except Exception: logger.debug("Exception executing job {0}".format(self._dbJobId)) - try: - job = dbScheduler.objects.select_for_update().get(id=self._dbJobId) - job.state = State.FOR_EXECUTE - job.owner_server = '' - job.next_execution = getSqlDatetime() + timedelta(seconds = job.frecuency) - # Update state and last execution time at database - job.save() - except Exception as e: - # Erased from database, nothing hapens - logger.exception(e) + self.save() + + def save(self): + done = False + while done is False: + try: + self.__save() + done = True + except: + # Erased from database, nothing hapens + # logger.exception(e) + logger.info('Database acces locked... Retrying') + time.sleep(1) + + + @transaction.commit_on_success + def __save(self): + job = dbScheduler.objects.select_for_update().get(id=self._dbJobId) + job.state = State.FOR_EXECUTE + job.owner_server = '' + job.next_execution = getSqlDatetime() + timedelta(seconds = job.frecuency) + # Update state and last execution time at database + job.save() class Scheduler(object): granularity = 2 # We check for cron jobs every THIS seconds diff --git a/server/src/uds/core/util/Cache.py b/server/src/uds/core/util/Cache.py index a4e1e5e4..3773afb8 100644 --- a/server/src/uds/core/util/Cache.py +++ b/server/src/uds/core/util/Cache.py @@ -50,7 +50,6 @@ class Cache(object): def __getKey(self, key): import os - logger.debug(os.environ) h = hashlib.md5() h.update(self._owner + key) return h.hexdigest()