Re: Django Channels - core.py error

2018-11-07 Thread Simon Vézina
Hi, 

I'm coming back with this one as well. I managed to fix my problem.  In my 
consumer, I was making normal Django database queries without the 
@database_sync_to_async decorator.

As soon as I started wrapping my code properly with this decorator, 
everything started to work fine. See below.

class NotificationConsumer (AsyncJsonWebsocketConsumer):
async def connect (self):
#do stuff

async def disconnect (self, code):
#do stuff

async def user_notification (self, event):
#do stuff

@database_sync_to_async
def get_notification (self, notification_pk):
return Notification.objects.filter(pk=notification_pk).first()

Hope this helps somebody else!

Le vendredi 31 août 2018 15:19:28 UTC-4, itsnate_b a écrit :
>
> I have the latest Django (2x), channels (2x), and redis/docker as of Aug 
> 31st, 2018 installed. I am encountering a django channels error and have no 
> idea why this is happening...has anyone seen this output? What is the 
> potential cause? Feeling pretty stuck with the error below...happens when 
> refreshing the site and an attempt is made to connect from js Websocket to 
> the python/channels backend.
>
>
> 2018-08-31 15:13:04,623 - ERROR - server - Exception inside application: 
>   File "/.../tests/lib/python3.6/site-packages/channels/sessions.py", line 
> 175, in __call__
> return await self.inner(receive, self.send)
>   File "/.../tests/lib/python3.6/site-packages/channels/middleware.py", 
> line 41, in coroutine_call
> await inner_instance(receive, send)
>   File "/.../tests/lib/python3.6/site-packages/channels/consumer.py", line 
> 54, in __call__
> await await_many_dispatch([receive, self.channel_receive], 
> self.dispatch)
>   File "/.../tests/lib/python3.6/site-packages/channels/utils.py", line 
> 57, in await_many_dispatch
> await task
>   File "/.../tests/lib/python3.6/site-packages/channels_redis/core.py", 
> line 400, in receive
> assert not self.receive_lock.locked()
>   
> [2018/08/31 15:13:04] WebSocket DISCONNECT /ws/dashboard/ [127.0.0.1:56102
> ]
>

-- 
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/1214626e-1722-454e-ac67-85b879fef3ab%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Channels - core.py error

2018-11-06 Thread Paul Whipp
I've just had trouble with exactly the same error. In my case I was 
building from the tutorial ChatConsumer with my own XChatConsumer and I 
hadn't referenced it in the routing.py. As a result the tutorial async chat 
consumer was receiving a scope that did not contain a room_name in its 
url_route kwargs. Very obscure! I think the channel gets closed by an error 
and then this 500 error comes up rather than anything helpful for the 
original error.

On Friday, 12 October 2018 07:06:13 UTC+10, itsnate_b wrote:
>
> Hi Simon,
>
> Sorry to hear that you are having the same problem! Channels can be a 
> blessing and a curse. I find it very finicky with very poor documentation & 
> poor error handling. As for the fix: I had an AsyncWebsocketConsumer class 
> in consumers.py within which I had a custom __init__ function. I believe I 
> was setting the scope incorrectly within the init. I realized that I had no 
> need to override/augment the init and removed it. The result was that the 
> error disappeared. That was it for me. I have since updated to all the 
> latest builds for the channels & redis infrastructure.
>
> Hope that helps.
>
> Cheers,
> Nathan
>
> On Tuesday, October 9, 2018 at 9:59:33 AM UTC-4, Simon Vézina wrote:
>>
>> Hi itsnate_b,
>>
>> Would you mind elaborating on your fix?
>>
>> I'm getting this exact error and I'm at a complete loss.   Everything 
>> works fine in local, but on my live server, after a couple of minutes/hours 
>> of working fine, I start getting this error in the logs.
>>
>> Thanks!
>>
>> Le dimanche 2 septembre 2018 13:26:29 UTC-4, itsnate_b a écrit :
>>>
>>> Turns out there was an erroneous *init* function in the 
>>> AsyncWebsocketConsumer class. Removing it fixed the issue.
>>>
>>

-- 
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/e1ebd5c9-5326-4d03-9512-f6f1deec28a3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Channels - core.py error

2018-10-11 Thread itsnate_b
Hi Simon,

Sorry to hear that you are having the same problem! Channels can be a 
blessing and a curse. I find it very finicky with very poor documentation & 
poor error handling. As for the fix: I had an AsyncWebsocketConsumer class 
in consumers.py within which I had a custom __init__ function. I believe I 
was setting the scope incorrectly within the init. I realized that I had no 
need to override/augment the init and removed it. The result was that the 
error disappeared. That was it for me. I have since updated to all the 
latest builds for the channels & redis infrastructure.

Hope that helps.

Cheers,
Nathan

On Tuesday, October 9, 2018 at 9:59:33 AM UTC-4, Simon Vézina wrote:
>
> Hi itsnate_b,
>
> Would you mind elaborating on your fix?
>
> I'm getting this exact error and I'm at a complete loss.   Everything 
> works fine in local, but on my live server, after a couple of minutes/hours 
> of working fine, I start getting this error in the logs.
>
> Thanks!
>
> Le dimanche 2 septembre 2018 13:26:29 UTC-4, itsnate_b a écrit :
>>
>> Turns out there was an erroneous *init* function in the 
>> AsyncWebsocketConsumer class. Removing it fixed the issue.
>>
>

-- 
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/228e579c-7967-4024-af57-fcf5ff7c10ca%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Channels - core.py error

2018-10-09 Thread Simon Vézina
Hi itsnate_b,

Would you mind elaborating on your fix?

I'm getting this exact error and I'm at a complete loss.   Everything works 
fine in local, but on my live server, after a couple of minutes/hours of 
working fine, I start getting this error in the logs.

Thanks!

Le dimanche 2 septembre 2018 13:26:29 UTC-4, itsnate_b a écrit :
>
> Turns out there was an erroneous *init* function in the 
> AsyncWebsocketConsumer class. Removing it fixed the issue.
>

-- 
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/1d38c986-74cf-42b6-a126-09df84caa2e2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Channels - core.py error

2018-09-02 Thread itsnate_b
Turns out there was an erroneous *init* function in the 
AsyncWebsocketConsumer class. Removing it fixed the issue.

On Saturday, September 1, 2018 at 1:23:10 PM UTC-4, itsnate_b wrote:
>
> I do not think it is even getting to the point where I can accept the 
> connection from within the consumers.pyand I'm not sure how to get a 
> better traceback than the one I already provided.
>
> On Saturday, September 1, 2018 at 1:20:16 PM UTC-4, itsnate_b wrote:
>>
>>
>> Hi Marius,
>> Thanks for the recommendation. Yes, I am using channel layers outside of 
>> consumers, however, this has not been an issue in the past. I am not clear 
>> on what you mean by "virtualenv best practices"? Yes, this is running in a 
>> venv, and it has worked in the past. I do think this issue is somehow 
>> driven by my setup..although any suggestions are welcome!
>>
>> My setup:
>> app1/
>> ...AsyncWebsocketConsumer (consumers.py)
>> ...AsyncConsumer (backgroundTask.py)
>> ..a couple other function files that call the get_channel_layer to send 
>> to a group
>> app2/
>> ...same idea
>>
>> On Saturday, September 1, 2018 at 9:40:10 AM UTC-4, Marius Räsener wrote:
>>>
>>> Hey, my guess is to check redis integration, f.e. like mentioned here at 
>>> the bottom (outside of consumers): 
>>> https://channels.readthedocs.io/en/latest/topics/channel_layers.html 
>>>
>>> next guess, since an unintended lock feels rather basic to me is to make 
>>> sure you‘re still following the virtualenv best practices? No Idea if 
>>> that’s worth mentioning or already clear but to be sure... 
>>>
>>> Good luck
>>
>>

-- 
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/13c23da8-97ba-4cf1-a4bc-31426e1faf1e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Channels - core.py error

2018-09-01 Thread itsnate_b
I do not think it is even getting to the point where I can accept the 
connection from within the consumers.pyand I'm not sure how to get a 
better traceback than the one I already provided.

On Saturday, September 1, 2018 at 1:20:16 PM UTC-4, itsnate_b wrote:
>
>
> Hi Marius,
> Thanks for the recommendation. Yes, I am using channel layers outside of 
> consumers, however, this has not been an issue in the past. I am not clear 
> on what you mean by "virtualenv best practices"? Yes, this is running in a 
> venv, and it has worked in the past. I do think this issue is somehow 
> driven by my setup..although any suggestions are welcome!
>
> My setup:
> app1/
> ...AsyncWebsocketConsumer (consumers.py)
> ...AsyncConsumer (backgroundTask.py)
> ..a couple other function files that call the get_channel_layer to send to 
> a group
> app2/
> ...same idea
>
> On Saturday, September 1, 2018 at 9:40:10 AM UTC-4, Marius Räsener wrote:
>>
>> Hey, my guess is to check redis integration, f.e. like mentioned here at 
>> the bottom (outside of consumers): 
>> https://channels.readthedocs.io/en/latest/topics/channel_layers.html 
>>
>> next guess, since an unintended lock feels rather basic to me is to make 
>> sure you‘re still following the virtualenv best practices? No Idea if 
>> that’s worth mentioning or already clear but to be sure... 
>>
>> Good luck
>
>

-- 
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/945d172f-d505-4175-90e1-c4ccc5c53a9d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Channels - core.py error

2018-09-01 Thread itsnate_b

Hi Marius,
Thanks for the recommendation. Yes, I am using channel layers outside of 
consumers, however, this has not been an issue in the past. I am not clear 
on what you mean by "virtualenv best practices"? Yes, this is running in a 
venv, and it has worked in the past. I do think this issue is somehow 
driven by my setup..although any suggestions are welcome!

My setup:
app1/
...AsyncWebsocketConsumer (consumers.py)
...AsyncConsumer (backgroundTask.py)
..a couple other function files that call the get_channel_layer to send to 
a group
app2/
...same idea

On Saturday, September 1, 2018 at 9:40:10 AM UTC-4, Marius Räsener wrote:
>
> Hey, my guess is to check redis integration, f.e. like mentioned here at 
> the bottom (outside of consumers): 
> https://channels.readthedocs.io/en/latest/topics/channel_layers.html 
>
> next guess, since an unintended lock feels rather basic to me is to make 
> sure you‘re still following the virtualenv best practices? No Idea if 
> that’s worth mentioning or already clear but to be sure... 
>
> Good luck

-- 
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/de71f291-c34d-44d9-a68d-ce8420ca9bb3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Django Channels - core.py error

2018-09-01 Thread Marius Räsener
Hey, my guess is to check redis integration, f.e. like mentioned here at the 
bottom (outside of consumers):
https://channels.readthedocs.io/en/latest/topics/channel_layers.html

next guess, since an unintended lock feels rather basic to me is to make sure 
you‘re still following the virtualenv best practices? No Idea if that’s worth 
mentioning or already clear but to be sure...

Good luck

-- 
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/075f20c5-3cc1-4a08-9480-62ac020f7ece%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Django Channels - core.py error

2018-08-31 Thread itsnate_b
I have the latest Django (2x), channels (2x), and redis/docker as of Aug 
31st, 2018 installed. I am encountering a django channels error and have no 
idea why this is happening...has anyone seen this output? What is the 
potential cause? Feeling pretty stuck with the error below...happens when 
refreshing the site and an attempt is made to connect from js Websocket to 
the python/channels backend.


2018-08-31 15:13:04,623 - ERROR - server - Exception inside application: 
  File "/.../tests/lib/python3.6/site-packages/channels/sessions.py", line 
175, in __call__
return await self.inner(receive, self.send)
  File "/.../tests/lib/python3.6/site-packages/channels/middleware.py", 
line 41, in coroutine_call
await inner_instance(receive, send)
  File "/.../tests/lib/python3.6/site-packages/channels/consumer.py", line 
54, in __call__
await await_many_dispatch([receive, self.channel_receive], 
self.dispatch)
  File "/.../tests/lib/python3.6/site-packages/channels/utils.py", line 57, 
in await_many_dispatch
await task
  File "/.../tests/lib/python3.6/site-packages/channels_redis/core.py", 
line 400, in receive
assert not self.receive_lock.locked()
  
[2018/08/31 15:13:04] WebSocket DISCONNECT /ws/dashboard/ [127.0.0.1:56102]

-- 
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/dc2a8aa4-ba28-4e90-b66a-8721f5573abf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.