Tuesday, July 31, 2018

Re: Problem with sending django channels event from models

Hello Andrew, sorry for the lack of traceback on the gist. I have changed my code a bit, i was using the `async_to_sync` but now i'm using this way inside my User save method:

channel_layer = get_channel_layer()
channel_layer.group_send(
    'users_{}'.format(self.pk), {
        'type': 'users.post_save',
        'user_pk': self.pk
    }
)

And everything works fine, but my tests are raising warnings on each test, like this, if you want to see the full traceback of my test, click here:

users/tests/test_consumers.py::test_user_consumer
  /Users/luan/Sources/channels-test/users/models.py:56: RuntimeWarning: coroutine 'RedisChannelLayer.group_send' was never awaited
    'user_pk': self.pk

I have update my gist, if you want to see something else, but in general i'm using py.test, as you can see in here.



Thanks for everything, Andrew.

Em sex, 27 de jul de 2018 às 19:30, Andrew Godwin <andrew@aeracode.org> escreveu:
You need to post the full traceback, not just the last section. I suspect what you are doing is calling model methods directly in an async function, but I can't confirm that without a full traceback.

Andrew

On Thu, Jul 26, 2018 at 1:10 PM luan fonceca <luanfonceca@gmail.com> wrote:
Hello, i'm trying to implement a "post_save" signal wherever some user are update. I setup everything by following the documentation and some tutorials for Channels 2. I wrote a test using "py.test" to assert that everything is working as expected but i'm getting a exception.


Thanks in advance.

--
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+unsubscribe@googlegroups.com.

--
You received this message because you are subscribed to a topic in the Google Groups "Django users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/django-users/3hZUiOvhSfE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to django-users+unsubscribe@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/CAFwN1uomro%2B1-qkGC8ThJw6ehz%3DHTenXwUqx-xM%3DkzzTqNgQdg%40mail.gmail.com.
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+unsubscribe@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/CAPqSnxuydxQaBGb0FkS%3DWvyxN5TwuuPmnJ5Yx3msBDNR36%3Dx0A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment