[FIX] multiprocess mode, empty the cursor pool before forking

bzr revid: al@openerp.com-20140122221525-hify023pk5i8d0jm
This commit is contained in:
Antony Lesuisse 2014-01-22 23:15:25 +01:00
parent 7dd432cd5d
commit 9248a2db18
2 changed files with 9 additions and 6 deletions

View File

@ -182,7 +182,6 @@ class CommonServer(object):
# runtime
self.pid = os.getpid()
def close_socket(self, sock):
""" Closes a socket instance cleanly
:param sock: the network socket to close
@ -530,6 +529,8 @@ class PreforkServer(CommonServer):
raise
def start(self):
# Empty the cursor pool, we dont want them to be shared among forked workers.
openerp.sql_db.close_all()
# wakeup pipe, python doesnt throw EINTR when a syscall is interrupted
# by a signal simulating a pseudo SA_RESTART. We write to a pipe in the
# signal handler to overcome this behaviour

View File

@ -27,9 +27,6 @@ the database, *not* a database abstraction toolkit. Database abstraction is what
the ORM does, in fact.
"""
__all__ = ['db_connect', 'close_db']
from functools import wraps
import logging
import psycopg2.extensions
@ -457,10 +454,10 @@ class ConnectionPool(object):
raise PoolError('This connection does not below to the pool')
@locked
def close_all(self, dsn):
def close_all(self, dsn=None):
_logger.info('%r: Close all connections to %r', self, dsn)
for i, (cnx, used) in tools.reverse_enumerate(self._connections):
if dsn_are_equals(cnx.dsn, dsn):
if dsn is None or dsn_are_equals(cnx.dsn, dsn):
cnx.close()
self._connections.pop(i)
@ -522,6 +519,11 @@ def close_db(db_name):
if _Pool:
_Pool.close_all(dsn(db_name))
def close_all():
global _Pool
if _Pool:
_Pool.close_all()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: