[FIX] hang in OSX when trying to shutdown server via SIGINT

bzr revid: xmo@tinyerp.com-20091127120938-arrvoqieit1bqx9c
This commit is contained in:
Xavier Morel 2009-11-27 13:09:38 +01:00
parent b676be9a97
commit fdcbed339b
1 changed files with 13 additions and 1 deletions

View File

@ -331,7 +331,19 @@ class HttpDaemon(threading.Thread):
def stop(self):
self.running = False
if os.name != 'nt':
self.server.socket.shutdown( hasattr(socket, 'SHUT_RDWR') and socket.SHUT_RDWR or 2 )
try:
self.server.socket.shutdown(
hasattr(socket, 'SHUT_RDWR') and socket.SHUT_RDWR or 2)
except socket.error, e:
if e.errno != 57: raise
# 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
Logger().notifyChannel(
'server', LOG_DEBUG,
'"%s" when shutting down server socket, '
'this is normal under OS X'%e)
self.server.socket.close()
def run(self):