jobserver.py 文件源码

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

项目:react-tornado-graphql-example 作者: yatsu 项目源码 文件源码
def countdown_handler(self, interval, count):
        command = '{0}/countdown -i {1} {2}'.format(os.getcwd(), interval, count)
        proc = Subprocess(shlex.split(command), stdout=Subprocess.STREAM)
        try:
            while True:
                line_bytes = yield proc.stdout.read_until(b'\n')
                line = to_unicode(line_bytes)[:-1]
                self.log.info('command read: %s', line)
                timestamp = datetime.now().timestamp()
                self.zmq_stream.send_multipart([b'0', utf8(json_encode({
                    'stdout': line,
                    'finished': False,
                    'timestamp': timestamp
                }))])
        except StreamClosedError:
            self.log.info('command closed')
            timestamp = datetime.now().timestamp()
            self.zmq_stream.send_multipart([b'0', utf8(json_encode({
                'stdout': None,
                'finished': True,
                'timestamp': timestamp
            }))])
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号