# runtime
self.pid = os.getpid()
-
def close_socket(self, sock):
""" Closes a socket instance cleanly
:param sock: the network socket to close
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
the ORM does, in fact.
"""
-
-__all__ = ['db_connect', 'close_db']
-
from functools import wraps
import logging
import psycopg2.extensions
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)
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: