Dennis Lee Bieber wrote: > On 27 Jul 2006 22:26:25 -0700, "placid" <[EMAIL PROTECTED]> declaimed the > following in comp.lang.python: > > > > > readline() blocks until the newline character is read, but when i use > > read(X) where X is a number of bytes then it doesnt block(expected > > functionality) but i dont know how many bytes the line will be and its > > not constant so i cant use this too. > > > > Any ideas of solving this problem? > > > Use a thread that reads one character at a time; when it sees > whatever signals "end of line" (it sounds like you're reading a progress > bar implemented via <cr>overwrite). Combine the characters into a > string, return the string to the main program via a queue. >
Yes it is a progress bar implemented via <cr> overwrite. I will try this. > If there is no such "end of line" character, but there IS a > noticeable delay between "writes", a more complex method might suffice > -- in which one thread does the byte reads, setting a time value on each > read; a related thread then does a sleep() loop, checking the "last read > time" against the pause length -- if close enough to the pause duration, > combine and return... i dont think there is a noticeable delay between "writes". > Alternatively, take a good old style terminal keyboard (a VT100 > Tempest-rated model should be ideal), and use it to beat Bill Gates over > the head until he agrees to push a high-priority upgrade to the command > line I/O system... or makes files work with select() (so you can combine > the time-out with the byte read) ;) Tsk Tsk -- http://mail.python.org/mailman/listinfo/python-list