[RuntimeError: no running event loop] with runworker in channels 2.3.1 with latest asgiref (3.4.0)
See original GitHub issueGetting the following error after installing django-channels with the runworker command. It’s working perfectly with asiref<3.4.0
$ python3 manage.py runworker background-task  --settings=config.settings.local
Running worker for channels ['background-task']
Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/Users/xxx/.pyenv/versions/cumulus_dev/lib/python3.8/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
    utility.execute()
  File "/Users/xxx/.pyenv/versions/cumulus_dev/lib/python3.8/site-packages/django/core/management/__init__.py", line 375, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/Users/xxx/.pyenv/versions/cumulus_dev/lib/python3.8/site-packages/django/core/management/base.py", line 323, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/Users/xxx/.pyenv/versions/cumulus_dev/lib/python3.8/site-packages/django/core/management/base.py", line 364, in execute
    output = self.handle(*args, **options)
  File "/Users/xxx/.pyenv/versions/cumulus_dev/lib/python3.8/site-packages/channels/management/commands/runworker.py", line 46, in handle
    worker.run()
  File "/Users/xxx/.pyenv/versions/cumulus_dev/lib/python3.8/site-packages/asgiref/server.py", line 59, in run
    event_loop = get_running_loop()
RuntimeError: no running event loop
pip freeze
asgiref==3.4.0
channels==2.3.1
channels-redis==2.4.1
daphne==2.4.0
Django==2.2.16
MacOS, python 3.8.4, pyenv
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:13 (3 by maintainers)
 Top Results From Across the Web
Top Results From Across the Web
RuntimeError: no running event loop Djnago runworker
I found this solution: Daphne + Channel v3 Deployment, RuntimeError: no running event loop but I already have asgiref==3.3.4.
Read more >RuntimeError - Bountysource
[RuntimeError: no running event loop] with runworker in channels 2.3.1 with latest asgiref (3.4.0)
Read more >Kostja Palović on Twitter: "downgraded to asgiref==3.3.4 locally ...
Okay, Django Channels websocket chat locally works. ... [RuntimeError: no running event loop] with runworker in channels 2.3.1 with latest asgiref (3.4.0).
Read more >Channels Documentation - Read the Docs
Underneath, Channels is running on a fully asynchronous event loop, and if you write code like above, it will get called.
Read more >daphne - PyPI
Daphne is a HTTP, HTTP2 and WebSocket protocol server for ASGI and ASGI-HTTP, developed to power Django Channels. It supports automatic negotiation of ......
Read more > Top Related Medium Post
Top Related Medium Post
No results found
 Top Related StackOverflow Question
Top Related StackOverflow Question
No results found
 Troubleshoot Live Code
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free Top Related Reddit Thread
Top Related Reddit Thread
No results found
 Top Related Hackernoon Post
Top Related Hackernoon Post
No results found
 Top Related Tweet
Top Related Tweet
No results found
 Top Related Dev.to Post
Top Related Dev.to Post
No results found
 Top Related Hashnode Post
Top Related Hashnode Post
No results found

Same issue here as I am going through the tutorial of Channels v3 at https://channels.readthedocs.io/en/stable/tutorial/index.html. Using asgiref==3.3.4 is okay.
🚀 🚀 🚀
It seems the issue is resolved in asgiref 3.5.0
https://github.com/django/asgiref/blob/8b615134bd481c4262356ad3194fbeff9240d0d3/CHANGELOG.txt#L7
Works On My Machine ™, closing issue!