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
}))])
评论列表
文章目录