作者kdjf (我抓得到什麽呢?)
看板Python
标题Re: [问题] threading / read from pipe的内容不完整
时间Mon Jul 18 12:55:29 2011
找到问题了...
没有东西被block掉
def reading():
while True:
scr=Conn.stdout.read(1)
drop=sys.stdout.buffer.write(scr)
=> drop=sys.stdout.flush() <=
DataIn=threading.Thread(target=reading)
DataIn.start()
在interactive shell里写东西到stdout,不用flush就看的到了
perhaps python implicitly flushed stdout before giving prompt.....
而且这个buffer不是OS的buffer...
看strace想了好久才搞定 = =" {
python先呼叫了select(),在interactive shell收到return後才write
而不是停在read(pipe)时}
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.112.245.32