1
0
mirror of https://github.com/dkmstr/openuds.git synced 2024-12-22 13:34:04 +03:00
This commit is contained in:
Adolfo Gómez 2012-11-12 19:29:51 +00:00
parent 37f4bf6caf
commit 96c95e8ff5
3 changed files with 25 additions and 12 deletions

View File

@ -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

View File

@ -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

View File

@ -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()