def try_readlines(self):
try:
while True:
msg = self.socket.recv(4096, socket.MSG_DONTWAIT)
yield msg.rstrip("\n")
except socket.error, e:
if e.errno == errno.EWOULDBLOCK or e.errno == errno.EAGAIN:
# this is expected when there's nothing in the socket queue
return
else:
raise # other error, rethrow
评论列表
文章目录