etianen / aiohttp-wsgi

WSGI adapter for aiohttp.
https://aiohttp-wsgi.readthedocs.io
BSD 3-Clause "New" or "Revised" License
232 stars 20 forks source link

Deployment instructions...? #6

Closed imdaveho closed 8 years ago

imdaveho commented 8 years ago

Just wondering if there are any caveats/instructions to deployment? (eg. in my case, I'm hoping to set up a quick development server with Heroku and wondering if I can use this wrapper with waitress). I'm assuming no, since aiohttp has it's own http server...but I know there is support for aiohttp with Gunicorn...

Let me know if this makes sense. I'm sure I may not be making the most sense as I'm just getting started with asyncio...and trying to make it work with Django...

etianen commented 8 years ago

There's no point running asyncio behind waitress, as waitress is only for serving sync requests. asyncio is all about the async requests.

The quickest way to get started with aiohttp-wsgi is the serve() method:

https://github.com/etianen/aiohttp-wsgi#serveapplication-kwargs

The example code provided is all you need to start an async server running your Django app. However, at this point, you're no better off than waitress, since all your requests will be served synchronously by Django.

The point of aiohttp-wsgi is that is allows a Django application to share the same port and router as an aiohttp application. That is, you can write the vast majority of your code as a simple Django application, with the bare minimum of async stuff living inside one or more aiohttp views.

On Wed, 23 Dec 2015 at 00:03 Dave Ho notifications@github.com wrote:

Just wondering if there are any caveats/instructions to deployment? (eg in my case, I'm hoping to set up a quick development server with Heroku and wondering if I can use this wrapper with waitress) I'm assuming no, since aiohttp has it's own http serverbut I know there is support for aiohttp with Gunicorn

Let me know if this makes sense I'm sure I may not be making the most sense as I'm just getting started with asyncioand trying to make it work with Django

— Reply to this email directly or view it on GitHub https://github.com/etianen/aiohttp-wsgi/issues/6.

imdaveho commented 8 years ago

@etianen Ahhh, I get it. The application is really Django + aiohttp.web app bundled together.

I'm new to the async world, so forgive my ignorance: to create a update pushing service like Trello or Google docs, for only a portion of the application, in which each user can collaborate in real-time, I'm thinking of using Django + asyncio + websockets + Redis (as described here, but with native asyncio in Python 3 instead of gevent)

Is it "better" to implement it that way or use this two framework bundled approach? Since I'm only trying to implement an asynchronous loop for a websocket connection only in a few sections of the application, would the above make more sense?

This probably is better left for a StackOverflow, but since you're here... If you want to just close this thread that's fine too; I understand that this isn't related to deployment or this library. Thanks for the responses thus far! Cheers.

etianen commented 8 years ago

In your case, I'd write the majority of the app in Django, since it's a great way to get the app working.

I'd then write the async parts using aiohttp websockets.

You can then glue the two parts together using aiohttp-wsgi!

On Wed, 23 Dec 2015 at 13:27 Dave Ho notifications@github.com wrote:

@etianen https://github.com/etianen Ahhh, I get it. The application is really Django + aiohttp.web app bundled together.

I'm new to the async world, so forgive my ignorance: to create a update pushing service like Trello or Google docs, for only a portion of the application, in which each user can collaborate in real-time, I'm thinking of using Django + asyncio + websockets + Redis (as described here https://django-websocket-redis.readthedocs.org/en/latest/introduction.html#uwsgi, but with native asyncio in Python 3 instead of gevent)

Is it "better" to implement it that way or use this two framework bundled approach? Since I'm only trying to implement an asynchronous loop for a websocket connection only in a few sections of the application, would the above make more sense?

This probably is better left for a StackOverflow, but since you're here... If you want to just close this thread that's fine too; I understand that this isn't related to deployment or this library. Thanks for the responses thus far! Cheers.

— Reply to this email directly or view it on GitHub https://github.com/etianen/aiohttp-wsgi/issues/6#issuecomment-166894249.