[FIX] multiprocess mode, empty the cursor pool before forking
bzr revid: al@openerp.com-20140122221525-hify023pk5i8d0jm
This commit is contained in:
parent
7dd432cd5d
commit
9248a2db18
|
@ -182,7 +182,6 @@ class CommonServer(object):
|
||||||
# runtime
|
# runtime
|
||||||
self.pid = os.getpid()
|
self.pid = os.getpid()
|
||||||
|
|
||||||
|
|
||||||
def close_socket(self, sock):
|
def close_socket(self, sock):
|
||||||
""" Closes a socket instance cleanly
|
""" Closes a socket instance cleanly
|
||||||
:param sock: the network socket to close
|
:param sock: the network socket to close
|
||||||
|
@ -530,6 +529,8 @@ class PreforkServer(CommonServer):
|
||||||
raise
|
raise
|
||||||
|
|
||||||
def start(self):
|
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
|
# 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
|
# by a signal simulating a pseudo SA_RESTART. We write to a pipe in the
|
||||||
# signal handler to overcome this behaviour
|
# signal handler to overcome this behaviour
|
||||||
|
|
|
@ -27,9 +27,6 @@ the database, *not* a database abstraction toolkit. Database abstraction is what
|
||||||
the ORM does, in fact.
|
the ORM does, in fact.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
__all__ = ['db_connect', 'close_db']
|
|
||||||
|
|
||||||
from functools import wraps
|
from functools import wraps
|
||||||
import logging
|
import logging
|
||||||
import psycopg2.extensions
|
import psycopg2.extensions
|
||||||
|
@ -457,10 +454,10 @@ class ConnectionPool(object):
|
||||||
raise PoolError('This connection does not below to the pool')
|
raise PoolError('This connection does not below to the pool')
|
||||||
|
|
||||||
@locked
|
@locked
|
||||||
def close_all(self, dsn):
|
def close_all(self, dsn=None):
|
||||||
_logger.info('%r: Close all connections to %r', self, dsn)
|
_logger.info('%r: Close all connections to %r', self, dsn)
|
||||||
for i, (cnx, used) in tools.reverse_enumerate(self._connections):
|
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()
|
cnx.close()
|
||||||
self._connections.pop(i)
|
self._connections.pop(i)
|
||||||
|
|
||||||
|
@ -522,6 +519,11 @@ def close_db(db_name):
|
||||||
if _Pool:
|
if _Pool:
|
||||||
_Pool.close_all(dsn(db_name))
|
_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:
|
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue