[issue1175] .readline() has bug WRT nonblocking files

2013-11-07 Thread Yuri Bochkarev
Changes by Yuri Bochkarev baltazar...@gmail.com: -- nosy: +Yuri.Bochkarev ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1175 ___ ___

[issue1175] .readline() has bug WRT nonblocking files

2007-09-19 Thread Guido van Rossum
Guido van Rossum added the comment: readline() goes through C stdio which makes it impossible to get non-blocking I/O right. You should be using raw os.read() calls (until python 3000 which will remove Python's reliance on C stdio). -- nosy: +gvanrossum resolution: - wont fix status:

[issue1175] .readline() has bug WRT nonblocking files

2007-09-18 Thread Alex Burr
New submission from Alex Burr: If you have made a file nonblocking using fcntl.fcntl, .readline() will discard the start of a line if you get EGAIN. It should attach the partial line to the exception somehow - or at least warn the user. I observe this on 2.3.5, but the same code exists in

[issue1175] .readline() has bug WRT nonblocking files

2007-09-18 Thread Sean Reifschneider
Sean Reifschneider added the comment: Doesn't the exception count as warning the user? We probably don't want to change readline to return a partial line in this case. An exception could be added for EGAIN that includes the partial line. Another option would be to just document the behavior

[issue1175] .readline() has bug WRT nonblocking files

2007-09-18 Thread Alex Burr
Alex Burr added the comment: The exception would count as a warning if it wasn't EGAIN. One expects to catch EGAIN and try again. The current situation is unfortunate because it *nearly* works. My scenario is: I'm driving GDB/MI via popen2.Popen3 ( gdbCommand, False,1). It works for most GDB

[issue1175] .readline() has bug WRT nonblocking files

2007-09-18 Thread Sean Reifschneider
Sean Reifschneider added the comment: Why are you putting the file in non-blocking mode? Why not just reading in blocking mode? If you want to do other work when a line is not available, you could use select to check to see if there's data ready via a small or 0 timeout.

[issue1175] .readline() has bug WRT nonblocking files

2007-09-18 Thread Sean Reifschneider
Sean Reifschneider added the comment: Arguably, you should be using select and read (instead of readline) for this operation. That's what I've done in the past when doing something similar. Specifically, I believe I have looped reading into a buffer with read, and using select with a timeout