gpt4 book ai didi

django-channels - builtins.RuntimeWarning : coroutine 'SyncToAsync.__call__' was never awaited

转载 作者:行者123 更新时间:2023-12-04 17:43:27 24 4
gpt4 key购买 nike

在调试丢弃的 channel_layer 消息问题时,我调高了 daphne verbosity 并且偶尔会在日志文件中看到如下所示的警告。真正的问题还是我可以忽略它们?

[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

这一切都在 AWS/EBS 上运行,ElastiCache 提供了 redis。如果有用和/或值得深入研究,我很乐意提供更多详细信息。

谢谢,凯文

最佳答案

是的,警告是真正的问题,但我的错误代码。

我的 WebsocketConsumer 派生类中缺少一些 async_to_sync 包装器,特别是用 @database_sync_to_async 装饰的 channels.auth.get_user()。

关于django-channels - builtins.RuntimeWarning : coroutine 'SyncToAsync.__call__' was never awaited,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53346567/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com