[REF] netsvc: close_socket is only used in wsgi_server, so move it there.

bzr revid: vmt@openerp.com-20130130174229-myvtydv03iikt6k3
This commit is contained in:
Vo Minh Thu 2013-01-30 18:42:29 +01:00
parent 8b5e317eab
commit 2910d5b3f6
2 changed files with 20 additions and 19 deletions

View File

@ -49,24 +49,6 @@ import openerp
_logger = logging.getLogger(__name__)
def close_socket(sock):
""" Closes a socket instance cleanly
:param sock: the network socket to close
:type sock: socket.socket
"""
try:
sock.shutdown(socket.SHUT_RDWR)
except socket.error, e:
# On OSX, socket shutdowns both sides if any side closes it
# causing an error 57 'Socket is not connected' on shutdown
# of the other side (or something), see
# http://bugs.python.org/issue4397
# note: stdlib fixed test, not behavior
if e.errno != errno.ENOTCONN or platform.system() not in ['Darwin', 'Windows']:
raise
sock.close()
class Service(object):
""" Base class for Local services
Functionality here is trusted, no authentication.

View File

@ -439,6 +439,25 @@ def stop_service():
"""
if httpd:
httpd.shutdown()
openerp.netsvc.close_socket(httpd.socket)
close_socket(httpd.socket)
def close_socket(sock):
""" Closes a socket instance cleanly
:param sock: the network socket to close
:type sock: socket.socket
"""
try:
sock.shutdown(socket.SHUT_RDWR)
except socket.error, e:
# On OSX, socket shutdowns both sides if any side closes it
# causing an error 57 'Socket is not connected' on shutdown
# of the other side (or something), see
# http://bugs.python.org/issue4397
# note: stdlib fixed test, not behavior
if e.errno != errno.ENOTCONN or platform.system() not in ['Darwin', 'Windows']:
raise
sock.close()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: