aboutsummaryrefslogtreecommitdiff
path: root/web
diff options
context:
space:
mode:
authorRobin H. Johnson <robbat2@gentoo.org>2007-11-24 18:33:22 +0000
committerRobin H. Johnson <robbat2@gentoo.org>2007-11-24 18:33:22 +0000
commite0b5fe8d8aec2f8acc7cdbc4d869011324186537 (patch)
tree58268bc36cb5a6bce448114b34de9c5b71dc15a6 /web
parentAdd TODO about sitemaps. (diff)
downloadpackages-e0b5fe8d8aec2f8acc7cdbc4d869011324186537.tar.gz
packages-e0b5fe8d8aec2f8acc7cdbc4d869011324186537.tar.bz2
packages-e0b5fe8d8aec2f8acc7cdbc4d869011324186537.zip
Log creation of threads, and also close memcached connections when we are done with using them. Setup time is very short, so it is more important to keep the FD count down.
Diffstat (limited to 'web')
-rw-r--r--web/controller.py7
-rw-r--r--web/model.py8
2 files changed, 15 insertions, 0 deletions
diff --git a/web/controller.py b/web/controller.py
index 78ca356..7e56b1e 100644
--- a/web/controller.py
+++ b/web/controller.py
@@ -87,6 +87,7 @@ class Root(object):
pagetitle = kwds['pagetitle']
kwds = sanitize_query_string(kwds)
+ db.close_mc()
return template.render(arches = arches,
daylist = day_list, center_pkgs = center_pkgs,
lastupdate = latest_entry, safeqs = kwds,
@@ -135,6 +136,7 @@ class Root(object):
http_lastmodified = lastmodified_httpheader(latest_entry)
cherrypy.response.headers['Last-Modified'] = http_lastmodified
kwds = sanitize_query_string(kwds)
+ db.close_mc()
return template.render(arches = arches,
daylist = day_list, center_pkgs = center_pkgs,
lastupdate = latest_entry, pagetitle = pagetitle,
@@ -173,6 +175,7 @@ class Root(object):
http_lastmodified = lastmodified_httpheader(latest_entry)
cherrypy.response.headers['Last-Modified'] = http_lastmodified
kwds = sanitize_query_string(kwds)
+ db.close_mc()
return template.render(arches = arches,
daylist = day_list, center_pkgs = center_pkgs,
lastupdate = latest_entry, pagetitle = pagetitle,
@@ -231,6 +234,7 @@ class Root(object):
http_lastmodified = lastmodified_httpheader(latest_entry)
cherrypy.response.headers['Last-Modified'] = http_lastmodified
kwds = sanitize_query_string(kwds)
+ db.close_mc()
return template.render(arches = arches,
daylist = day_list, center_pkgs = center_pkgs,
lastupdate = latest_entry, pagetitle = pagetitle,
@@ -286,6 +290,7 @@ class Root(object):
pagetitle = 'Categories'
kwds = sanitize_query_string(kwds)
+ db.close_mc()
return template.render(arches = arches,
daylist = day_list, center_categories = rows,
lastupdate = latest_entry, safeqs = kwds, sums = sums,
@@ -338,6 +343,7 @@ class Root(object):
http_lastmodified = lastmodified_httpheader(latest_entry)
cherrypy.response.headers['Last-Modified'] = http_lastmodified
kwds = sanitize_query_string(kwds)
+ db.close_mc()
return template.render(arches = arches,
daylist = day_list, center_pkgs = center_pkgs,
lastupdate = latest_entry, pagetitle = pagetitle,
@@ -395,6 +401,7 @@ class Root(object):
http_lastmodified = lastmodified_httpheader(latest_entry)
cherrypy.response.headers['Last-Modified'] = http_lastmodified
kwds = sanitize_query_string(kwds)
+ db.close_mc()
return template.render(arches = arches,
daylist = day_list, center_pkgs = center_pkgs,
lastupdate = latest_entry, pagetitle = pagetitle,
diff --git a/web/model.py b/web/model.py
index 3a2baf1..dc1301e 100644
--- a/web/model.py
+++ b/web/model.py
@@ -2,6 +2,7 @@ from time import localtime, strftime, time
import datetime
import re, sys
import operator
+import cherrypy
from pkgcore.ebuild.cpv import CPV
from DBUtils.PersistentDB import PersistentDB
@@ -93,6 +94,7 @@ class PackageDB(object):
self.dbconfig.update(config)
if 'memcached' in config and config['memcached']:
+ cherrypy.log("Thread started", "THREAD")
import memcache
servers = config['memcached']['servers']
args = config['memcached']['args']
@@ -110,10 +112,16 @@ class PackageDB(object):
#traceback.print_stack(file=sys.stdout)
db = self.db.connection()
return db.cursor()
+
def close_db(self):
"""Force the DB conenction to be closed"""
self.db._closeable = True
self.db.connection.close()
+
+ def close_mc(self):
+ """Force the Memcached connection to be closed"""
+ if 'memcached' in self.dbconfig and self.dbconfig['memcached']:
+ self.mc.disconnect_all()
def _preparesql(self):
"""Prepare all SQL statements for the relevant DB backend"""