STINNER Victor <victor.stin...@haypocalc.com> added the comment:

io_interlaced_read_write.patch:
 - add interlaced read/write tests for BufferedRandom and BufferedRWPair
 - _pyio: move "undo readahead" code into BufferedReader.flush()
 - io: BufferedRandom.flush() doesn't undo readahead if the write buffer is 
empty, so it's possible to call it in read methods without flusing the 
readahead buffer when it's not needed
 - read(), read1(), readinto(), peek() calls writer.flush()
 - write() calls reader.flush() (undo readahead)

TODO:
 - tests BufferedRWPair with read-only + write-only files because I'm not sure 
if my tests using readable and writeable methods
 - _pyio: undo the readahead in BufferedReader.flush() is no perfect, because 
BufferedReader is supposed to be read-only. I choosed that to factorize the 
code between BufferedRandom and BufferedRWPair
 - what happens if a write occurs during _pyio.BufferedReader.flush()? "if 
self._read_buf: <write occurs> with self._read_lock: ...". We may protect the 
read of self._read_buf with the read lock.

My patch tries to fix interlaced read-write by always calling flush(), but I am 
not sure that it doesn't change read-only and write-only cases. There are maybe 
some unnecessary call to flush().

----------
keywords: +patch
Added file: http://bugs.python.org/file22190/io_interlaced_read_write.patch

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue12213>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to