Fix tests when running for long time

This commit is contained in:
shortcutme 2019-12-17 14:34:29 +01:00
parent 6539ca5eb0
commit e91fb90a45
No known key found for this signature in database
GPG key ID: 5B63BAE6CB9613AE
3 changed files with 9 additions and 3 deletions

View file

@ -25,7 +25,7 @@ class ContentDbPlugin(object):
self.my_optional_files = {} # Last 50 site_address/inner_path called by fileWrite (auto-pinning these files) self.my_optional_files = {} # Last 50 site_address/inner_path called by fileWrite (auto-pinning these files)
self.optional_files = collections.defaultdict(dict) self.optional_files = collections.defaultdict(dict)
self.optional_files_loading = False self.optional_files_loading = False
helper.timer(60 * 5, self.checkOptionalLimit) self.timer_check_optional = helper.timer(60 * 5, self.checkOptionalLimit)
super(ContentDbPlugin, self).__init__(*args, **kwargs) super(ContentDbPlugin, self).__init__(*args, **kwargs)
def getSchema(self): def getSchema(self):

View file

@ -19,6 +19,8 @@ def importPluginnedClasses():
def processAccessLog(): def processAccessLog():
if access_log: if access_log:
content_db = ContentDbPlugin.content_db content_db = ContentDbPlugin.content_db
if not content_db.conn:
return False
now = int(time.time()) now = int(time.time())
num = 0 num = 0
for site_id in access_log: for site_id in access_log:
@ -33,6 +35,8 @@ def processAccessLog():
def processRequestLog(): def processRequestLog():
if request_log: if request_log:
content_db = ContentDbPlugin.content_db content_db = ContentDbPlugin.content_db
if not content_db.conn:
return False
cur = content_db.getCursor() cur = content_db.getCursor()
num = 0 num = 0
for site_id in request_log: for site_id in request_log:

View file

@ -186,7 +186,8 @@ def site(request):
def cleanup(): def cleanup():
site.delete() site.delete()
site.content_manager.contents.db.close() site.content_manager.contents.db.close("Test cleanup")
site.content_manager.contents.db.timer_check_optional.kill()
SiteManager.site_manager.sites.clear() SiteManager.site_manager.sites.clear()
db_path = "%s/content.db" % config.data_dir db_path = "%s/content.db" % config.data_dir
os.unlink(db_path) os.unlink(db_path)
@ -213,7 +214,8 @@ def site_temp(request):
def cleanup(): def cleanup():
site_temp.delete() site_temp.delete()
site_temp.content_manager.contents.db.close() site_temp.content_manager.contents.db.close("Test cleanup")
site_temp.content_manager.contents.db.timer_check_optional.kill()
db_path = "%s-temp/content.db" % config.data_dir db_path = "%s-temp/content.db" % config.data_dir
os.unlink(db_path) os.unlink(db_path)
del ContentDb.content_dbs[db_path] del ContentDb.content_dbs[db_path]