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