作者kdjf (我抓得到什麽呢?)
看板Python
标题[问题] threading / read from pipe的内容不完整
时间Wed Jul 13 10:16:51 2011
呃... 我也觉得标题很烂,
请大家提示一下要怎麽下这个标题吧 <(_ _)>
我现在想要写一个ptt(bbs)的wraper
用ssh连线,现在还在很原始的阶段,code在下面
当没有绿色的部份(让ssh直接写到tty)时,bbs的操作是OK的
可是加上後,会在一个萤幕还没画完时就卡着
操作的指令还有用,可是画面会很乱
不知到是ssh还是python被block, 还是?
os:linux, python3.1.2
----------------
bbs=['ssh', '
[email protected]']
import sys, tty, subprocess, threading #为了放进一页的ptt
Conn=subprocess.Popen(bbs, stdin=subprocess.PIPE,
# stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
def reading():
while True:
scr=Conn.stdout.read(1)
drop=sys.stdout.buffer.write(scr)
#DataIn=threading.Thread(target=reading)
#DataIn.start()
tty.setraw(1)
while True:
char=sys.stdin.buffer.read(1)
drop=Conn.stdin.write(char)
Conn.stdin.flush()
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.112.245.32