Re: Django Channels AuthMiddleware question

2018-03-04 Thread Andrew Godwin
This is a problem with _any_ ASGI app, not just middleware - doing blocking things in the __init__ is bad. I will look at the docs when I look at solving the SessionMiddleware problem as well, as the two are linked. Andrew On Sun, Mar 4, 2018 at 7:10 AM, Hugo Castilho wrote: > > > The example

Re: Django Channels AuthMiddleware question

2018-03-04 Thread Hugo Castilho
The example in the Channels documentation shows it being used with a consumer called consumers.AsyncChatConsumer which suggests it's safe to use with async consumers. There probably should be a note there that it's currently not safe to use with async consumers no? Regarding the SessionMiddle

Re: Django Channels AuthMiddleware question

2018-03-03 Thread Andrew Godwin
Hi Hugo, The AuthMiddleware, like its Django counterpart, does not query the auth backend immediately - it is lazily done the first time you access the scope["user"] object. This does present a risk that you could access it during an async method body, though - I will look into how we could fix th

Django Channels AuthMiddleware question

2018-03-03 Thread Hugo Castilho
Hi all, The channels authentication documentation (https://channels.readthedocs.io/en/latest/topics/authentication.html) shows using the channels AuthMiddleware with an AsyncConsumer. Now, my problem is that all session backends in Django are blocking. I know that the user is only retrieved la