question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[RuntimeError: no running event loop] with runworker in channels 2.3.1 with latest asgiref (3.4.0)

See original GitHub issue

Getting 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:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:13 (3 by maintainers)

github_iconTop GitHub Comments

6reactions
boonlengcommented, Aug 6, 2021

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.

5reactions
bj00rncommented, Jan 24, 2022

🚀 🚀 🚀

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!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found