Fix infinite exception loop: KeyError Exception in callback None

This commit is contained in:
Florian Mounier
2014-05-16 12:00:05 +02:00
parent f9c9700062
commit d7298f6229

View File

@@ -307,22 +307,29 @@ class TermWebSocket(Route, tornado.websocket.WebSocketHandler):
read = ''
self.log.info('READ>%r' % read)
if len(read) != 0 and self.ws_connection:
if read and len(read) != 0 and self.ws_connection:
self.write_message(read.decode('utf-8', 'replace'))
else:
events = ioloop.ERROR
if events & ioloop.ERROR:
self.log.info('Error on fd, closing')
self.log.info('Error on fd %d, closing' % fd)
# Terminated
self.on_close()
self.close()
def on_close(self):
self.log.info('Closing fd %d' % self.fd)
if getattr(self, 'pid', 0) == 0:
self.log.info('pid is 0')
return
try:
ioloop.remove_handler(self.fd)
except Exception:
self.log.error('handler removal fail', exc_info=True)
try:
os.close(self.fd)
except Exception:
@@ -334,9 +341,4 @@ class TermWebSocket(Route, tornado.websocket.WebSocketHandler):
except Exception:
self.log.debug('waitpid fail', exc_info=True)
try:
ioloop.remove_handler(self.fd)
except Exception:
self.log.debug('handler removal fail', exc_info=True)
self.log.info('Websocket closed')