Error performing an async for on an AgnosticCursor with _get_more method

Hi @Robert_DiFalco, I believe the error you are seeing is the same as python - RuntimeError: await wasn't used with future when using twisted, pytest_twisted plugin, and asyncio reactor - Stack Overflow, and is related to pytest_twisted itself. The following pure-asyncio code runs with pytest without error:

import asyncio
from motor.motor_asyncio import AsyncIOMotorClient


test_db_uri = 'mongodb://localhost/test'

async def print_results():
    client = AsyncIOMotorClient(test_db_uri)
    db = client.get_default_database()
    col = db.get_collection("test")
    async for doc in col.find({}):
        print(doc)


def test_this():
    asyncio.run(print_results())
1 Like