Close on empty read

This commit is contained in:
Florian Mounier
2014-03-04 11:07:57 +01:00
parent 6d4dda0aef
commit 8e07b75a00
2 changed files with 10 additions and 9 deletions

View File

@@ -60,7 +60,7 @@ B ` '
888b R'"B ,', R"'B d888
j888888bd8gf"' ':' `"?g8bd888888k
R'Y'B .8' d' 'b '8. R'Y'X
R!B .8' RdbB d'; ;`b RdbB '8. R!
R!B .8' RdbB d'; ;`b RdbB '8. R!B
d88 R`'B 8 ; ; 8 R`'B 88b Rbutterfly Zv %sB
d888b .g8 ',' 8g. d888b
:888888888Y' 'Y888888888: AConnecting to:B
@@ -245,13 +245,14 @@ class TermWebSocket(Route, tornado.websocket.WebSocketHandler):
try:
read = self.reader.read()
except IOError:
pass
read = ''
self.log.info('READ>%r' % read)
if len(read) != 0 and self.ws_connection:
self.write_message(read.decode('utf-8', 'replace'))
else:
self.log.info('READ>%r' % read)
if self.ws_connection:
self.write_message(read.decode('utf-8', 'replace'))
else:
events = ioloop.ERROR
events = ioloop.ERROR
if events & ioloop.ERROR:
self.log.info('Error on fd, closing')
# Terminated

View File

@@ -87,7 +87,7 @@ class Socket(object):
self.user = User(uid=int(line[7]))
self.env = get_socket_env(line[9])
except Exception:
log.debug('procfs was no good, aight')
log.debug('procfs was no good, aight', exc_info=True)
if self.user is None:
# Try with lsof
@@ -95,7 +95,7 @@ class Socket(object):
self.user = User(name=get_lsof_socket_line(
self.remote_addr, self.remote_port)[1])
except Exception:
log.debug('lsof was no good either')
log.debug('lsof was no good', exc_info=True)
@property
def local(self):