diff --git a/odoo/sql_db.py b/odoo/sql_db.py index 31299df03bd..ed7edcfa130 100644 --- a/odoo/sql_db.py +++ b/odoo/sql_db.py @@ -26,6 +26,7 @@ from psycopg2.pool import PoolError from psycopg2.sql import SQL, Identifier from werkzeug import urls +import odoo from . import tools from .tools.func import frame_codeinfo, locked @@ -764,7 +765,10 @@ _Pool = None def db_connect(to, allow_uri=False): global _Pool if _Pool is None: - _Pool = ConnectionPool(int(tools.config['db_maxconn'])) + _Pool = ConnectionPool(int( + odoo.evented and tools.config['db_maxconn_gevent'] + or tools.config['db_maxconn'] + )) db, info = connection_info_for(to) if not allow_uri and db != to: diff --git a/odoo/tools/config.py b/odoo/tools/config.py index 099b4e34ed9..a697f3299ba 100644 --- a/odoo/tools/config.py +++ b/odoo/tools/config.py @@ -259,6 +259,8 @@ class configmanager(object): help="specify the database ssl connection mode (see PostgreSQL documentation)") group.add_option("--db_maxconn", dest="db_maxconn", type='int', my_default=64, help="specify the maximum number of physical connections to PostgreSQL") + group.add_option("--db_maxconn_gevent", dest="db_maxconn_gevent", type='int', my_default=False, + help="specify the maximum number of physical connections to PostgreSQL specifically for the gevent worker") group.add_option("--db-template", dest="db_template", my_default="template0", help="specify a custom database template to create a new database") parser.add_option_group(group) @@ -448,7 +450,7 @@ class configmanager(object): 'db_port', 'db_template', 'logfile', 'pidfile', 'smtp_port', 'email_from', 'smtp_server', 'smtp_user', 'smtp_password', 'from_filter', 'smtp_ssl_certificate_filename', 'smtp_ssl_private_key_filename', - 'db_maxconn', 'import_partial', 'addons_path', 'upgrade_path', + 'db_maxconn', 'db_maxconn_gevent', 'import_partial', 'addons_path', 'upgrade_path', 'syslog', 'without_demo', 'screencasts', 'screenshots', 'dbfilter', 'log_level', 'log_db', 'log_db_level', 'geoip_city_db', 'geoip_country_db', 'dev_mode',