Question about wsgi.input

Diez B. Roggisch deets at nospam.web.de
Mon May 26 15:38:27 EDT 2008


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