server.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:wtee 作者: gvalkov 项目源码 文件源码
def on_stdin(self, fd, events):
        data = fd.read()
        lines = data.splitlines(True)

        # TODO: Use the value of '--input-encoding' here.
        decoded_data = data.decode('utf8', errors='replace')
        lines = decoded_data.splitlines(True)
        if lines:
            if not lines[-1].endswith('\n'):
                self.last_line.append(lines[-1])
                lines = lines[:-1]
            else:
                if self.last_line:
                    lines[0] = ''.join(self.last_line) + lines[0]
                    self.last_line = []

        self.broadcast(self.clients, escape.json_encode(lines))
        self.stdout_buffer.write(data)
        self.stdout_buffer.flush()

        # TODO: Empty string and None mean different things with os.O_NONBLOCK.
        if not data:
            log.debug('stdin closed')
            self.stdin_closed = True
            self.disable_stdin_handler()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号