[Python-Dev] wsgi validator with asynchronous handlers/servers (original) (raw)
Benjamin Peterson benjamin at python.org
Sat Mar 23 20:19:40 CET 2013
- Previous message: [Python-Dev] wsgi validator with asynchronous handlers/servers
- Next message: [Python-Dev] wsgi validator with asynchronous handlers/servers
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hi, The people who best understand WSGI are to be found on the Web-SIG: http://mail.python.org/mailman/listinfo/web-sig
2013/3/23 Luca Sbardella <luca.sbardella at gmail.com>:
Hi,
I have an asynchronous wsgi application handler which yields empty bytes before it is ready to yield the response body and, importantly, to call startresponse. Something like this: def wsgihandler(environ, startresponse): body = generatebody(environ) body = maybeasync(body) while isasync(body): yield b'' startresponse(...) ... I started using wsgiref.validator recently, nice little gem in the standard lib, and I discovered that the above handler does not validate! Disaster. Reading pep 3333 "the application must invoke the startresponse() callable before the iterable yields its first body bytestring, so that the server can send the headers before any body content. However, this invocation may be performed by the iterable's first iteration, so servers must not assume that startresponse() has been called before they begin iterating over the iterable." The pseudocode above does yields bytes before startresponse, but they are not body bytes, they are empty bytes so that the asynchronous wsgi server releases the eventloop and call back at the next eventloop iteration. I'm I misinterpreting the pep, or the wsgi validator should be fixed accordingly? Regards, Luca
Python-Dev mailing list Python-Dev at python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/benjamin%40python.org
-- Regards, Benjamin
- Previous message: [Python-Dev] wsgi validator with asynchronous handlers/servers
- Next message: [Python-Dev] wsgi validator with asynchronous handlers/servers
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]