AttributeError:“_UnixSelectorEventLoop”对象没有属性“_signal_handlers”
Posted
技术标签:
【中文标题】AttributeError:“_UnixSelectorEventLoop”对象没有属性“_signal_handlers”【英文标题】:AttributeError: '_UnixSelectorEventLoop' object has no attribute '_signal_handlers' 【发布时间】:2021-11-06 10:25:14 【问题描述】:我一直在将我们的 Django/Python 应用程序升级到 Python 3.9.7 和 Django 3.2.7(从 Python 3.5 和 Django 1.11.23)。
目前如果我尝试运行python manage.py createsuperuser
我收到以下错误
Traceback (most recent call last):
File "/Users/myuser/.pyenv/versions/3.9.7/lib/python3.9/asyncio/selector_events.py", line 261, in _add_reader
key = self._selector.get_key(fd)
File "/Users/myuser/.pyenv/versions/3.9.7/lib/python3.9/selectors.py", line 193, in get_key
raise KeyError("!r is not registered".format(fileobj)) from None
KeyError: '10 is not registered'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/myuser/Development/app/manage.py", line 22, in <module>
execute_from_command_line(sys.argv)
File "/Users/myuser/.pyenv/versions/insta9/lib/python3.9/site-packages/django/core/management/__init__.py", line 419, in execute_from_command_line
utility.execute()
File "/Users/myuser/.pyenv/versions/insta9/lib/python3.9/site-packages/django/core/management/__init__.py", line 413, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Users/myuser/.pyenv/versions/insta9/lib/python3.9/site-packages/django/core/management/base.py", line 367, in run_from_argv
connections.close_all()
File "/Users/myuser/.pyenv/versions/insta9/lib/python3.9/site-packages/django/db/utils.py", line 213, in close_all
connection.close()
File "/Users/myuser/.pyenv/versions/insta9/lib/python3.9/site-packages/django/utils/asyncio.py", line 19, in inner
event_loop = asyncio.get_event_loop()
File "/Users/myuser/.pyenv/versions/3.9.7/lib/python3.9/asyncio/events.py", line 639, in get_event_loop
self.set_event_loop(self.new_event_loop())
File "/Users/myuser/.pyenv/versions/3.9.7/lib/python3.9/asyncio/events.py", line 659, in new_event_loop
return self._loop_factory()
File "/Users/myuser/.pyenv/versions/3.9.7/lib/python3.9/asyncio/unix_events.py", line 54, in __init__
super().__init__(selector)
File "/Users/myuser/.pyenv/versions/3.9.7/lib/python3.9/asyncio/selector_events.py", line 61, in __init__
self._make_self_pipe()
File "/Users/myuser/.pyenv/versions/3.9.7/lib/python3.9/asyncio/selector_events.py", line 112, in _make_self_pipe
self._add_reader(self._ssock.fileno(), self._read_from_self)
File "/Users/myuser/.pyenv/versions/3.9.7/lib/python3.9/asyncio/selector_events.py", line 263, in _add_reader
self._selector.register(fd, selectors.EVENT_READ,
File "/Users/myuser/.pyenv/versions/3.9.7/lib/python3.9/selectors.py", line 523, in register
self._selector.control([kev], 0, 0)
TypeError: changelist must be an iterable of select.kevent objects
Exception ignored in: <function BaseEventLoop.__del__ at 0x103307310>
Traceback (most recent call last):
File "/Users/myuser/.pyenv/versions/3.9.7/lib/python3.9/asyncio/base_events.py", line 683, in __del__
self.close()
File "/Users/myuser/.pyenv/versions/3.9.7/lib/python3.9/asyncio/unix_events.py", line 63, in close
if self._signal_handlers:
AttributeError: '_UnixSelectorEventLoop' object has no attribute '_signal_handlers'
Exception ignored in: <function BaseEventLoop.__del__ at 0x103307310>
Traceback (most recent call last):
File "/Users/myuser/.pyenv/versions/3.9.7/lib/python3.9/asyncio/base_events.py", line 683, in __del__
self.close()
File "/Users/myuser/.pyenv/versions/3.9.7/lib/python3.9/asyncio/unix_events.py", line 63, in close
if self._signal_handlers:
AttributeError: '_UnixSelectorEventLoop' object has no attribute '_signal_handlers'
这些是我在 requirements.txt 中使用的一些版本
Django==3.2.7
django-braces==1.14.0
django-pipeline==2.0.6
django-storages==1.11.1
djangorestframework==3.12.4
django-localflavor==2.0
django-redis==5.0.0
django_guardian==2.4.0
django-debug-toolbar==3.2.2
django-grappelli==2.15.1
django-extensions==3.1.3
django-simple-history==3.0.0
django-cities-light==3.8.1
django-autoslug==1.9.8
django-constance==2.8.0
django-jsonify==0.3.0
django-bulk-update==2.2.0
django-sslserver==0.22
django-admin-easy==0.6.1
django-admin-rangefilter==0.8.1
django-model-utils==4.1.1
gunicorn==19.7.1
honcho==0.7.1
ipython==5.6.0
eventlet==0.32.0
selenium==2.53.2
这似乎也发生在我运行服务器时,然后再次终止服务器。有什么想法可能导致该问题吗?
【问题讨论】:
【参考方案1】:有时您不需要异步功能来运行应用程序。在这种情况下,设置允许异步不安全。
export DJANGO_ALLOW_ASYNC_UNSAFE=True
【讨论】:
以上是关于AttributeError:“_UnixSelectorEventLoop”对象没有属性“_signal_handlers”的主要内容,如果未能解决你的问题,请参考以下文章
AttributeError: 'RDD' 对象没有属性 'show'
AttributeError:“NumpyArrayIterator”对象没有属性“类”
AttributeError:模块 'dbus' 没有属性 'lowlevel'