[Python-Dev] io.BufferedReader.peek() Behaviour in python3.1
Cameron Simpson
cs at zip.com.au
Tue Jun 16 04:03:11 CEST 2009
On 16Jun2009 02:18, MRAB <python at mrabarnett.plus.com> wrote:
>> My itch is that peek() _feels_ like it should be "look into the buffer"
>> but actually can block and/or change the buffer.
>>
> Can block, but not if you don't want it too. You might just want to see
> what, if anything, is currently available, up to n bytes.
Am I missing something?
In the face of an _empty_ buffer (which I can't tell from outside) how
do I prevent peek() blocking? More generally, if I go peek(n) and if n >
bytes_in_buffer_right_now and the raw stream would block if a raw read
is done?
My concerns would go away if I could probe the buffer content size;
then I could ensure peek(n) chose n <= the content size. If that's not
enough, my problem - I can choose to read-and-block or go away and come
back later.
--
Cameron Simpson <cs at zip.com.au> DoD#743
http://www.cskk.ezoshosting.com/cs/
If all around you is darkness and you feel you're contending in vain,
then the light at the end of the tunnel is the front of an oncoming train.
More information about the Python-Dev
mailing list