Python -- Django 中使用协和异步中出现的问题
Django 中使用协程异步出现的问题问题You cannot call this from an async context - use a thread or sync_to_async原因:你在异步线路中又去调了同步的线路所以…解决办法:from django.contrib.auth.models import Userfrom asgiref.sync import sync_to_asyncimport asyncio@sync_to_asyncdef get_users
原创
2022-03-10 16:24:08 ·
1936 阅读 ·
0 评论