forked from shaba/openuds
Merge remote-tracking branch 'origin/v1.9'
This commit is contained in:
commit
162c84e21c
@ -32,7 +32,7 @@ DATABASES = {
|
||||
'PASSWORD': 'PASSWOR', # Not used with sqlite3.
|
||||
'HOST': 'localhost', # Set to empty string for localhost. Not used with sqlite3.
|
||||
'PORT': '3306', # Set to empty string for default. Not used with sqlite3.
|
||||
'CONN_MAX_AGE': 600, # Enable DB Pooling, 10 minutes max connection duration
|
||||
# 'CONN_MAX_AGE': 600, # Enable DB Pooling, 10 minutes max connection duration
|
||||
}
|
||||
}
|
||||
ALLOWED_HOSTS = '*'
|
||||
@ -121,6 +121,9 @@ CACHES = {
|
||||
'MAX_ENTRIES': 5000,
|
||||
'CULL_FREQUENCY': 3, # 0 = Entire cache will be erased once MAX_ENTRIES is reached, this is faster on DB. if other value, will remove 1/this number items fromm cache
|
||||
}
|
||||
},
|
||||
'memory': {
|
||||
'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,7 @@
|
||||
'''
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import transaction
|
||||
from django.db import transaction, connection
|
||||
from django.db.models import Q
|
||||
from uds.models import DelayedTask as dbDelayedTask
|
||||
from uds.models import getSqlDatetime
|
||||
@ -44,7 +44,7 @@ import threading
|
||||
import time
|
||||
import logging
|
||||
|
||||
__updated__ = '2015-01-21'
|
||||
__updated__ = '2015-10-15'
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@ -173,6 +173,10 @@ class DelayedTaskRunner(object):
|
||||
try:
|
||||
time.sleep(self.granularity)
|
||||
self.executeOneDelayedTask()
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
logger.error('Unexpected exception at run loop {0}: {1}'.format(e.__class__, e))
|
||||
try:
|
||||
connection.close()
|
||||
except Exception:
|
||||
logger.exception('Exception clossing connection at delayed task')
|
||||
logger.info('Exiting DelayedTask Runner because stop has been requested')
|
||||
|
@ -43,7 +43,7 @@ import threading
|
||||
import time
|
||||
import logging
|
||||
|
||||
__updated__ = '2015-10-05'
|
||||
__updated__ = '2015-10-15'
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@ -79,7 +79,11 @@ class JobThread(threading.Thread):
|
||||
done = True
|
||||
except Exception:
|
||||
# Databases locked, maybe because we are on a multitask environment, let's try again in a while
|
||||
logger.info('Database access locked... Retrying')
|
||||
try:
|
||||
connection.close()
|
||||
except Exception as e:
|
||||
logger.error('On job executor, closing db connection: {}'.format(e))
|
||||
logger.info('Database access failed... Retrying')
|
||||
time.sleep(1)
|
||||
|
||||
# Ensures DB connection is released after job is done
|
||||
@ -160,7 +164,8 @@ class Scheduler(object):
|
||||
# This in fact means that we have to retry operation, and retry will happen on main loop
|
||||
# Look at this http://dev.mysql.com/doc/refman/5.0/en/innodb-deadlocks.html
|
||||
# I have got some deadlock errors, but looking at that url, i found that it is not so abnormal
|
||||
logger.debug('Deadlock, no problem at all :-) (sounds hards, but really, no problem, will retry later :-) )')
|
||||
# logger.debug('Deadlock, no problem at all :-) (sounds hards, but really, no problem, will retry later :-) )')
|
||||
raise DatabaseError('Database access problems. Retrying connection')
|
||||
|
||||
@staticmethod
|
||||
def releaseOwnShedules():
|
||||
@ -185,7 +190,11 @@ class Scheduler(object):
|
||||
try:
|
||||
time.sleep(self.granularity)
|
||||
self.executeOneJob()
|
||||
except Exception, e:
|
||||
logger.exception('Unexpected exception at run loop {0}: {1}'.format(e.__class__, e))
|
||||
except Exception as e:
|
||||
logger.error('Unexpected exception at run loop {0}: {1}'.format(e.__class__, e))
|
||||
try:
|
||||
connection.close()
|
||||
except Exception:
|
||||
logger.exception('Exception clossing connection at delayed task')
|
||||
logger.info('Exiting Scheduler because stop has been requested')
|
||||
self.releaseOwnShedules()
|
||||
|
@ -51,7 +51,7 @@ import requests
|
||||
import json
|
||||
import logging
|
||||
|
||||
__updated__ = '2015-05-27'
|
||||
__updated__ = '2015-10-15'
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@ -480,12 +480,12 @@ class UserServiceManager(object):
|
||||
data=json.dumps({'user': userName, 'protocol': protocol}),
|
||||
headers={'content-type': 'application/json'},
|
||||
verify=False,
|
||||
timeout=5)
|
||||
timeout=2)
|
||||
r = json.loads(r.content)
|
||||
logger.debug('Sent pre connection to client using {}: {}'.format(url, r))
|
||||
# In fact we ignore result right now
|
||||
except Exception as e:
|
||||
logger.error('Exception caught notifiying preConnection: {}. Check connection on destination machine: {}'.format(e, url))
|
||||
logger.info('preConnection failed: {}. Check connection on destination machine: {}'.format(e, url))
|
||||
|
||||
def sendScript(self, uService, script):
|
||||
'''
|
||||
|
Loading…
Reference in New Issue
Block a user