在调试掉落的channel_layer消息问题时,我打开了daphne的详细信息,偶尔在日志文件中看到类似以下的警告。实际问题还是我可以忽略它们?
[ec2-user@ip-aaa-bb-c-dd ~]$ grep SyncToAsync /var/log/daphne/error_log | head
2018-11-16 11:51:03,898 daphne.server WARNING /opt/python/run/venv/local/lib/python3.6/site-packages/channels_redis/core.py:282: builtins.RuntimeWarning: coroutine 'SyncToAsync.__call__' was never awaited
2018-11-16 11:51:17,025 daphne.server WARNING /usr/lib64/python3.6/logging/__init__.py:277: builtins.RuntimeWarning: coroutine 'SyncToAsync.__call__' was never awaited
2018-11-16 11:51:28,523 daphne.server WARNING /usr/lib64/python3.6/asyncio/selector_events.py:316: builtins.RuntimeWarning: coroutine 'SyncToAsync.__call__' was never awaited
2018-11-16 11:51:40,559 daphne.server WARNING /usr/lib64/python3.6/selectors.py:191: builtins.RuntimeWarning: coroutine 'SyncToAsync.__call__' was never awaited
2018-11-16 11:51:51,824 daphne.server WARNING /usr/lib64/python3.6/asyncio/tasks.py:313: builtins.RuntimeWarning: coroutine 'SyncToAsync.__call__' was never awaited
2018-11-16 11:52:03,066 daphne.server WARNING /opt/python/run/venv/local/lib/python3.6/site-packages/django/db/models/query.py:862: builtins.RuntimeWarning: coroutine 'SyncToAsync.__call__' was never awaited
2018-11-16 11:53:20,962 daphne.server WARNING /opt/python/run/venv/local/lib64/python3.6/site-packages/twisted/web/http.py:244: builtins.RuntimeWarning: coroutine 'SyncToAsync.__call__' was never awaited
2018-11-16 11:56:51,245 daphne.server WARNING /opt/python/run/venv/local/lib64/python3.6/site-packages/twisted/web/http.py:2994: builtins.RuntimeWarning: coroutine 'SyncToAsync.__call__' was never awaited
2018-11-16 11:57:16,160 daphne.server WARNING /usr/lib64/python3.6/threading.py:347: builtins.RuntimeWarning: coroutine 'SyncToAsync.__call__' was never awaited
2018-11-16 11:57:21,295 daphne.server WARNING /opt/python/run/venv/local/lib64/python3.6/site-packages/twisted/internet/tcp.py:196: builtins.RuntimeWarning: coroutine 'SyncToAsync.__call__' was never awaited
作为参考,以下是我使用的版本:
aioredis==1.2.0
asgiref==2.3.2
async-timeout==3.0.1
attrs==18.2.0
autobahn==18.11.1
Automat==0.7.0
channels==2.1.5
channels-redis==2.3.1
constantly==15.1.0
daphne==2.2.3
Django==2.1.3
django-health-check==3.8.0
django-redis-cache==1.8.0
hiredis==0.2.0
hyperlink==18.0.0
idna==2.7
incremental==17.5.0
msgpack==0.5.6
mysqlclient==1.3.13
PyHamcrest==1.9.0
pytz==2018.7
redis==2.10.6
six==1.11.0
Twisted==18.9.0
txaio==18.8.1
zope.interface==4.6.0
这一切都在带有ElastiCache提供redis的AWS / EBS上运行。我很乐意提供更多详细信息,如果它有用和/或值得进一步研究。
谢谢, 凯文
答案 0 :(得分:0)
是的,警告是真实的问题,但是带有我的错误代码。
我在WebsocketConsumer派生类中缺少一些async_to_sync包装器,特别是对于用@database_sync_to_async装饰的channels.auth.get_user()。