KERNEL: add option for max_conn for psycopg connection

bzr revid: ced-970f464819315f9a80765cacbb3821bdacf3aa7a
This commit is contained in:
ced 2007-05-02 10:36:56 +00:00
parent 87118d6535
commit f10f808aa9
2 changed files with 5 additions and 2 deletions

View File

@ -116,7 +116,8 @@ def db_connect(db_name):
name = "dbname=%s" % db_name
user = tools.config['db_user'] and "user=%s" % tools.config['db_user'] or ''
password = tools.config['db_password'] and "password=%s" % tools.config['db_password'] or ''
tdb = psycopg.connect('%s %s %s %s %s' % (host, port, name, user, password), serialize=0)
maxconn = int(tools.config['db_maxconn']) or 64
tdb = psycopg.connect('%s %s %s %s %s' % (host, port, name, user, password), serialize=0, maxconn=maxconn)
fdb = fakedb(tdb, db_name)
return fdb

View File

@ -45,6 +45,7 @@ class configmanager(object):
'db_name': 'terp',
'db_user': False,
'db_password': False,
'db_maxconn': 64,
'reportgz': False,
'netrpc': True,
'xmlrpc': True,
@ -100,6 +101,7 @@ class configmanager(object):
group.add_option("--pg_path", dest="pg_path", help="specify the pg executable path")
group.add_option("--db_host", dest="db_host", help="specify the database host")
group.add_option("--db_port", dest="db_port", help="specify the database port")
group.add_option("--db_maxconn", dest="db_maxconn", default='64', help="specify the the maximum number of physical connections to posgresql")
parser.add_option_group(group)
group = optparse.OptionGroup(parser, "Internationalisation options",
@ -139,7 +141,7 @@ class configmanager(object):
self.options['pidfile'] = False
for arg in ('interface', 'port', 'db_name', 'db_user', 'db_password', 'db_host',
'db_port', 'logfile', 'pidfile', 'secure', 'smtp_server', 'price_accuracy', 'netinterface', 'netport'):
'db_port', 'logfile', 'pidfile', 'secure', 'smtp_server', 'price_accuracy', 'netinterface', 'netport', 'db_maxconn'):
if getattr(opt, arg):
self.options[arg] = getattr(opt, arg)