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
this (it might mean making it non-lazy, but I don't quite know yet).

The SessionMiddleware does have the problem you suggest, though - I have
opened this issue to track it: https://github.com/django/channels/issues/949

Andrew

On Sat, Mar 3, 2018 at 5:49 PM, Hugo Castilho <hcasti...@gmail.com> wrote:

>
> 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 lazily but from what I understand
> this only means that instead of the blocking call happening during the
> instantiation of the application in daphne.Server.create_application it
> will happen in the AsyncConsumer.
> Either way the call will be made in the event loop.
> Are we not stopping the event loop for the first time every connection
> accesses request.user?
> I'm sure I'm missing something here.
>
> Thanks!
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/f9a7ec05-7d54-4459-a08a-20d6a931c8a3%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/f9a7ec05-7d54-4459-a08a-20d6a931c8a3%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAFwN1uoC97nwCEsCX5kyVHZuzv2qFWdsf8JotGq7et5QM0kaGQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to