-
-
Notifications
You must be signed in to change notification settings - Fork 788
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RuntimeError: Event loop is closed when following tutorial #1966
Comments
Thanks for the report. You can run the shell with That's probably a nicer rewrite to have anyway, if you fancied making that. Out of interest, what happens if you use |
This gives the same error.
Nice! This works. The drawbacks are that you need to manually add the DJANGO_SETTINGS_MODULE environment variable and calling asynchronous functions with |
Hi @sean-reed. I've tracked it down. The move to redis-py requires closing connections explicitly
So to get the shell example to pass cleanly we need to do something like this: >>> import channels.layers
>>> from asgiref.sync import async_to_sync
>>>
>>> channel_layer = channels.layers.get_channel_layer()
>>>
>>> async def closing_send(channel_layer, channel, message):
... await channel_layer.send(channel, message)
... await channel_layer.close_pools()
>>>
>>> async_to_sync(closing_send)(channel_layer,'test_channel', {'type': 'hello'})
>>> async_to_sync(channel_layer.receive)('test_channel')
{'type': 'hello'} Even then we should do the same for the receive call really. (A further call would hit the same issue.) I'll have a think about the best addition to the docs. |
This should be resolved by channels-redis 4.1, which will automatically close the redis connection at loop shutdown. |
Great news. Do you know when this release will be available ? |
It's already out. |
I see no tag nor release on github and on pypi it's still the version 4.0.0: https://pypi.org/project/channels/ Am I missing something ? |
Channels-redis. |
oh my bad. Sorry 🙂 |
…ntimeError: Event loop is closed' (django/channels#1966 (comment))
…ntimeError: Event loop is closed' (django/channels#1966 (comment))
…ntimeError: Event loop is closed' (django/channels#1966 (comment))
…ntimeError: Event loop is closed' (django/channels#1966 (comment))
…is from 4.0 to 4.1 to fix error 'RuntimeError: Event loop is closed' (django/channels#1966 (comment))
I get the following error when following the official Channels tutorial at this step (specifically, when checking the channel layer can communicate with Redis using the Django shell):
I was using the current channels-redis version (4.0.0) that is installed when following the tutorial. Seems to be related to this issue django/channels_redis#332.
Downgrading to channels-redis version 3.4.1 fixes the issue. I suggest updating the tutorial to
python3 -m pip install channels-redis===3.4.1
until channels-redis fix the issue.
The text was updated successfully, but these errors were encountered: