Question about wsgi.input

inhahe inhahe at gmail.com
Mon May 26 15:52:23 EDT 2008


That's what I would have thought, just seems strange since it seems to imply 
that if I use StringIO or cStringIO, then whenever i write to it i have to 
save the position, seek to the end, write, and then seek to the position i 
saved.  Are there any other classes that are more suitable for pipes, but 
qualify as 'file-like objects'?

"Diez B. Roggisch" <deets at nospam.web.de> wrote in message 
news:6a0htmF35sj8eU1 at mid.uni-berlin.de...
> inhahe schrieb:
>> I'm sorry if this is off-topic, i couldn't find a mailing list OR forum 
>> for WSGI (and #wsgi wasn't very helpful).
>>
>> i played around with StringIO, and apparently if you write to a stringio 
>> the position gets set to the end of the write, so if you read from it 
>> again, without using seek, you won't read what comes next, you'll skip to 
>> the end of the write.  and if you write without seeking to the end first, 
>> you'll overwrite part of the string if the reading hasn't caught up.
>>
>> WSGI says that wsgi.input should block if there's more data to be read 
>> from the socket, until that data is available. so when the server writes 
>> to the file object, what happens to the file position? if i were writing 
>> a WSGI app, i would just seek() to the last place my read ended at just 
>> to make sure.  but i'm making a server, so i need to know whether i 
>> should leave the position at the end of the write, when it blocks (or for 
>> that matter, if i'm writing while it's still reading), or at the end of 
>> the previous read?
>
> I'm not sure exactly about what you are talking here - but generally, 
> wsgi.input should be considerd being a pipe. One (the server) simply 
> writes into it. The WSGI-app just reads. No seek.
>
> Diez 





More information about the Python-list mailing list