Python 在Django3项目中使用Motor或任何其他异步MongoDB驱动程序

Python 在Django3项目中使用Motor或任何其他异步MongoDB驱动程序,python,django,mongodb,asynchronous,Python,Django,Mongodb,Asynchronous,在Django 3项目中,是否有任何方法使用电机或任何其他异步MongoDB驱动程序 我首先尝试使用motor客户端:motor\u asyncio.AsyncIOMotorClient,然后尝试使用motor\u tornado.MotorClient 第一个引发了以下异常: Task <Task pending coro=<SessionMiddlewareInstance.__call__() running at SOMEWHERE>> got Future &l

在Django 3项目中,是否有任何方法使用电机或任何其他异步MongoDB驱动程序

我首先尝试使用motor客户端:
motor\u asyncio.AsyncIOMotorClient
,然后尝试使用motor\u tornado.MotorClient

第一个引发了以下异常:

Task <Task pending coro=<SessionMiddlewareInstance.__call__() running at SOMEWHERE>> got Future <Future pending cb=[run_on_executor.<locals>._call_check_cancel() at SOMEWHERE]> attached to a different loop
任务已附加到另一个循环
第二个方法不会引发任何异常,但它会在我使用
insert\u one
方法在db中插入消息的那一行停止

有没有办法异步插入和读取MongoDB中的数据



编辑:在Django中必须有一种使用
motor\u asyncio
客户端的方法。有人知道怎么做吗?

我有同样的问题,如果您将motor与Django会话管理一起使用,异常概念是正确的,因为Django支持中间件并异步查看工作的第二阶段,我建议您在setting.py中创建instance
client motor
,然后使用它。