channels: runserver raise error.ReactorAlreadyInstalledError("reactor already installed")

Now I add channels to project by installation guide from docs

  • OS and runtime environment virtualenv with Python 3.5.3 [GCC 6.3.0 20170118] on linux / debian Jessie

  • The versions of Channels, Daphne, Django, Twisted daphne==2.0.0 Django==2.0.2 Twisted==17.9.0

  • What you expected to happen vs. what actually happened python src/manage.py runserver 8925 and get raise error.ReactorAlreadyInstalledError(“reactor already installed”)

  • How you’re running Channels (runserver? daphne/runworker? Nginx/Apache in front?) on localhost just python src/manage.py runserver 8925

  • Console logs and full tracebacks of any errors

$ ls src
apps
project_src 
manage.py  

$ ls src/project_src/
asgi.py  
__init__.py  
locale
routing.py
settings  
static  
templates  
urls.py  
wsgi.py

ROOT_URLCONF = ‘project_src.urls’ WSGI_APPLICATION = ‘project_src.wsgi.application’ ASGI_APPLICATION = “project_src.routing.application”

(.venv3) berg@berg-dell:/Working-dir/$python src/manage.py runserver 8925
Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x7f4155431e18>
Traceback (most recent call last):
  File "/Working-dir/.venv3/lib/python3.5/site-packages/django/utils/autoreload.py", line 225, in wrapper
    fn(*args, **kwargs)
  File "/Working-dir/.venv3/lib/python3.5/site-packages/django/core/management/commands/runserver.py", line 113, in inner_run
    autoreload.raise_last_exception()
  File "/Working-dir/.venv3/lib/python3.5/site-packages/django/utils/autoreload.py", line 248, in raise_last_exception
    raise _exception[1]
  File "/Working-dir/.venv3/lib/python3.5/site-packages/django/core/management/__init__.py", line 327, in execute
    autoreload.check_errors(django.setup)()
  File "/Working-dir/.venv3/lib/python3.5/site-packages/django/utils/autoreload.py", line 225, in wrapper
    fn(*args, **kwargs)
  File "/Working-dir/.venv3/lib/python3.5/site-packages/django/__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/Working-dir/.venv3/lib/python3.5/site-packages/django/apps/registry.py", line 89, in populate
    app_config = AppConfig.create(entry)
  File "/Working-dir/.venv3/lib/python3.5/site-packages/django/apps/config.py", line 116, in create
    mod = import_module(mod_path)
  File "/Working-dir/.venv3/lib/python3.5/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 986, in _gcd_import
  File "<frozen importlib._bootstrap>", line 969, in _find_and_load
  File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 673, in exec_module
  File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
  File "/Working-dir/.venv3/lib/python3.5/site-packages/channels/apps.py", line 6, in <module>
    import daphne.server  # noqa
  File "/Working-dir/.venv3/lib/python3.5/site-packages/daphne/server.py", line 3, in <module>
    asyncioreactor.install()  # isort:skip
  File "/Working-dir/.venv3/lib/python3.5/site-packages/twisted/internet/asyncioreactor.py", line 322, in install
    installReactor(reactor)
  File "/Working-dir/.venv3/lib/python3.5/site-packages/twisted/internet/main.py", line 32, in installReactor
    raise error.ReactorAlreadyInstalledError("reactor already installed")
twisted.internet.error.ReactorAlreadyInstalledError: reactor already installed

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 23 (15 by maintainers)

Most upvoted comments

import channels.apps

?

Oof, if it’s in sentry/raven a lot of people are going to run into this.

the problem was in the configuration sentry logger https://docs.sentry.io/clients/python/integrations/django/

localy I disable raven, but sentry config was stay exists in LOGGING setting after comment this section, all worked

    'handlers': {
#         'sentry': {
#             'level': 'ERROR',  # To capture more than ERROR, change to WARNING, INFO, etc.
#             'class': 'raven.contrib.django.raven_compat.handlers.SentryHandler',
#             'tags': {'custom-tag': 'x'},
#         },