Closed schmitch closed 10 years ago
Well, aiohttp is not fully wsgi compliant server and it won't. Wsgi spec doesn't say anything about asyncio coroutines. It is possible to make it compliant with readpayload=true parameter, but this is not for production, it reads payload into memory
I thought it is compatible with pep-3156? But it isn't. It still says:
http client/server for asyncio (PEP-3156)
Ah, sorry. I thought about wsgi specs.
Intention for DataQueue is different from StreamReader. You can wrap payload into StreamReader very easily.
Regarding compatibility with pep-3156, it says nothing about http. That was one of the reasons why we moved http code from asyncio to separate project.
I could, but if I wrap them I would need to write my own program. But what happens if I use gunicorn with django? It will fail horribly. So only gunicorn could fix this up, or I would need to write my own 'gunicorn'. Best would be to just include that.
Also PEP-3156 says something about http.
A few functions and classes are provided to simplify the writing of basic stream-based clients and servers, such as FTP or HTTP. Thes are:
It is an Interface and Interfaces should be implemented in my eyes. But who cares.
gjango will fail horribly, because it is doesn't work with asyncio. Asyncio doesn't work like gevent, you can not just install aiohttp and make your application asynchronous. For non trivial application you have to rewrite it to use asyncio.
I don't understated "Interface" part of your comment. Could you elaborate.
Won't fix
@fafhrd91 not sure but why a buffered stream reader could not be used there? if buffer is empty or < n it could eventually claim for more data until eof.
DataQueue is not a bytes stream, it just holds arbitrary objects that parser emits. for example WebSocketParser emits aiohttp.websocket.Message named tuples. if application requires it is very easy to wrap DataQueue into StreamReader.
@fafhrd91 if it can be done easily, i think it would be good to have it imo :)
sure, if somebody explain how i can do byte streaming on arbitrary objects, like tuples :)
From my experience, you can't access to POST variables in a Flask application without a stacktrace with Gunicorn. No idea to resolve that, but it looses the interest if we can't use main WSGI frameworks with that.
there is a way. we can change "readpayload" to True, then wsgi.input will work as expected. but this will mean that payload gets loaded into memory.
@asvetlov @benoitc thoughts?
@benoitc how others workers in Gunicorn work to read payload? If they also load all in memory, "readpayload" to True is acceptable.
@GMLudo sync, thread and the default gevent/eventlet workers are streaming the data. they don't keep the full body in memory.
readpayload is to True in gaiohttp worker.
well I still think there should be a way to stream it. Should it be another ticket?
i've just created #87
Thanks!
On Sat, Jun 28, 2014 at 8:23 PM, Nikolay Kim notifications@github.com wrote:
i've just created #87 https://github.com/KeepSafe/aiohttp/issues/87
— Reply to this email directly or view it on GitHub https://github.com/KeepSafe/aiohttp/issues/81#issuecomment-47434721.
Currently the python spec says that there are several utilities methods that needs to be implemented: http://legacy.python.org/dev/peps/pep-3156/#servers
One is really important the
read(n)
method. Also two other methods are missing.readline()
andreadexcatly(n)
if aiohttp won't cover these method it isn't compatible to 3156 and won't work with a lot of projects.Edit: Here is the class that misses these methods: https://github.com/KeepSafe/aiohttp/blob/master/aiohttp/parsers.py#L281