https://www.cnpython.com/pypi/aiomongo
github说明
https://github.com/easeliu/aiomongo
import asyncio
import aiomongo
async def main(loop):
client = await aiomongo.create_client('mongodb://localhost:27017/test?w=2&maxpoolsize=10', loop=loop)
db = client.get_default_database()
await db.items.insert_one({'x': 1})
await db.items.delete_one({'x': 1})
client.close()
await client.wait_closed()
if __name__ == '__main__':
loop = asyncio.get_event_loop()
loop.run_until_complete(main(loop))
async with db.items.find().batch_size(10).limit(100) as cursor:
async for item in cursor:
print(item)