[Web-SIG] ngx.poll extension (was Re: Are you going to convert Pylons code into Python 3000?)

brian at tmbx.com brian at tmbx.com
Fri Mar 7 15:18:45 CET 2008


>Manlio Perillo wrote:
>> Brian Smith wrote:

>> For "non-blocking reads", given environ["wsgi.input"].read(64000,
>> min=8000):
>>
>> 1. If more than 64000 bytes are available without blocking, [64000] bytes
>> are returned.
>> 2. If less than 8000 bytes are available without blocking, then the
>> gateway blocks until at least [8000] bytes are available.
>> 3. When 8000-63999 bytes are available, then all those bytes are
>> returned.

I made some typos when I was editing the above description. I have
corrected them by replacing the typos with the corrected text in
[brackets]. I hope it makes more sense now.

Additionally:

4. If the "min" parameter is absent, or less than zero, then it defaults
to being equal to the first argument (i.e. the current always-blocking
behavior).

5. There is no way to distinguish "no input available yet" from EOF, when
min=0 using just read(). Instead, some other mechanism must be used to
detect EOF if true non-blocking reads (min=0) are used. The vast majority
of the time, keeping a count of the bytes read and comparing to
CONTENT_LENGTH will be enough.

Note also that calling this "non-blocking" is really not precise, because
sometimes it does block due to rule #2 above.

- Brian



More information about the Web-SIG mailing list