pty difficulties
Justin Dubs
jtdubs at eos.ncsu.edu
Sat Jan 24 12:12:23 EST 2004
Josiah Carlson <jcarlson at nospam.uci.edu> wrote in message news:<butccm$2un$1 at news.service.uci.edu>...
> > while True:
> > readable = select(connections.keys(), [], [])[0]
> > for f in readable:
> > data = read(f.fileno(), 1024)
> > connections[f].write(data)
> > connections[f].flush()
>
> I believe your problem exists in the write and flush. All you seem to
> be doing is checking to see if your reading file handles are capable of
> reading, you never check to see if you can write to anything. Your lisp
> interpreter showcases the fact that it is not ready to get a write while
> it is interpreting, by failing. I believe the following should fix you up:
>
> while True:
> readable = select(connections.keys(), [], [])[0]
> for f in readable:
> if select([], [connections[f]], [], 0)[1]:
> data = read(f.fileno(), 1024)
> connections[f].write(data)
> connections[f].flush()
Thanks for the suggestions, but this didn't help. I should have
mentioned that I had tried this before. Here's the code I had used:
while True:
readable, writeable, ignore = select(connections.keys(),
connections.values(), [])
for f in readable:
if connections[f] in writeable:
data = read(f.fileno(), 1024)
connections[f].write(data)
connections[f].flush()
I don't think checking for writeable status /should/ help because the
write call I am using blocks. So, if the stream isn't writeable, it
should just block until it is. I think.
Justin Dubs
More information about the Python-list
mailing list