def keep_writing(self):
"""Input thread method for the process
Sends the user inputs (from InputTranscoder) to the process
"""
while True:
if self.stop:
break
ret = self.process.poll()
if ret is not None:
self.stop = True
readable, writable, executable = select.select([], [self.master], [], 5)
if writable:
try:
(input_type, content) = self.input_transcoder.pop_input(timeout=1)
except Empty:
pass
else:
if input_type == 0:
log_debug("Sending input\n<< {}".format(repr(content)))
data = content.encode('UTF-8')
# data = bytes(chaine, 'iso-8859-15')
while data:
chars_written = os.write(self.master, data)
data = data[chars_written:]
elif input_type == 1:
(signal_type, signal_content) = content
t = fcntl.ioctl(self.master, signal_type, signal_content)
log_debug(struct.unpack('HHHH', t))
elif input_type == 2:
os.killpg(os.getpgid(self.process.pid), content)
log_debug("SENDING SIGNAL TO PROCESS", content)
评论列表
文章目录