Ok, your solution also works, but where in the documentation does it say that \n will be replaced with “”?
I consider this clearly unexpected behavior — it should be either patched or documented
I cannot reproduce, perhaps a local environment issue. Also Motor is now deprecated and End of Life next year.
As of May 14, 2025, Motor is deprecated in favor of the GA release of the PyMongo Async API in the PyMongo library. We will not add new features to Motor, and we will provide only bug fixes until it reaches end of life on May 14, 2026. After that, we will fix only critical bugs until final support ends on May 14, 2027. We strongly recommend migrating to the PyMongo Async API while Motor is still supported.
For more information about migrating, see the Migrate to PyMongo Async guide in the PyMongo documentation.
# app
import asyncio
import os
from motor.motor_asyncio import AsyncIOMotorClient
async def runit():
uri = os.getenv('MONGODB_URI','mongodb://localhost')
client = AsyncIOMotorClient(uri)
try:
resp = await client.test.foo.find().to_list(length=500)
print(resp)
except Exception as e:
print(e)
asyncio.run(runit())
Okay, I’m trying to perform a transaction using PyMongo Async, but I can’t get it to work because there’s no documentation about GridFS. Currently, I’m using AsyncIOMotorGridFSBucket.
Then somehow I found that there’s also from gridfs.asynchronous import AsyncGridFSBucket.
But overall, this is a terrible experience migrating to async.