[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:
parent
8b5e317eab
commit
2910d5b3f6
|
@ -49,24 +49,6 @@ import openerp
|
||||||
_logger = logging.getLogger(__name__)
|
_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):
|
class Service(object):
|
||||||
""" Base class for Local services
|
""" Base class for Local services
|
||||||
Functionality here is trusted, no authentication.
|
Functionality here is trusted, no authentication.
|
||||||
|
|
|
@ -439,6 +439,25 @@ def stop_service():
|
||||||
"""
|
"""
|
||||||
if httpd:
|
if httpd:
|
||||||
httpd.shutdown()
|
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:
|
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||||
|
|
Loading…
Reference in New Issue