Closed NicolasLM closed 6 years ago
It's a nice idea. I suspect that it can be done very easily by adapting the functions in main. I don't have time to do it myself right now, but I would review a pull request that added a public aiohttp_wsgi.serve() method, with accompanying documentation.
On 2 February 2018 at 13:00, Nicolas Le Manchet notifications@github.com wrote:
aiohttp-wsgi has a way to serve WSGI apps from the CLI, but there is no easy way to do it from Python code. By easy I mean with a single function call.
The serve function in main is almost good for this use case, except that it expects args from the CLI.
For inspiration, I really like how waitress does it with waitress.serve https://docs.pylonsproject.org/projects/waitress/en/latest/#usage.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/etianen/aiohttp-wsgi/issues/20, or mute the thread https://github.com/notifications/unsubscribe-auth/AAJFCC1dC8D-Xx8bnscAtPmadVgiuvIDks5tQwcIgaJpZM4R3JkG .
This is awesome, thank you!
You might have noticed that a lot of the public API for aiohttp-wsgi takes it's inspiration from waitress already. The new serve
function, along with the existing CLI, are pretty much drop-in replacements.
I'm not 100% convinced there's any reason to use aiohttp-wsgi over waitress if there's no intention to use any async features. I'd be curious to see a performance comparison of the two servers for a hello world WSGI app. I have no idea which one would be faster!
For me the reason is quite simple: waitress uses Python asyncore
which is deprecated and may be removed completely from Python at some point. It also has seen little to no development lately.
By using asyncio you're basically using the blessed asynchronous framework for Python which is a good thing.
I did a small benchmark with wrk
and waitress is slightly faster but there is some room for improvement. For instance disabling the aiohttp
access log raises a 15% speedup.
Cool stuff. We've been using some copy-pasted and glued together bits of the main up until now. Motivation can pretty much be summed up in that we want to run other asyncio tasks in the same process without adding another async concept like threads to the picture
aiohttp-wsgi
has a way to serve WSGI apps from the CLI, but there is no easy way to do it from Python code. By easy I mean with a single function call.The
serve
function in__main__
is almost good for this use case, except that it expects args from the CLI.For inspiration, I really like how waitress does it with
waitress.serve
.