File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- motor
21dill
32python-dotenv
43fastapi
54uvloop
65pydantic
76numpy == 1.26.4
8- pymongo
7+ pymongo >= 4.15
98jsonpickle
109gunicorn
1110uvicorn
Original file line number Diff line number Diff line change 1212from pydantic import ValidationError
1313from pymongo .errors import PyMongoError
1414from pymongo .server_api import ServerApi
15- from motor .motor_asyncio import AsyncIOMotorClient
15+ from pymongo import AsyncMongoClient
16+
1617from fastapi import HTTPException , status
1718from bson import ObjectId
1819
@@ -135,7 +136,7 @@ def _initialize_connection(self):
135136 self ._connection_string = Secrets .get_secret (
136137 "MONGODB_CONNECTION_STRING"
137138 )
138- self ._client = AsyncIOMotorClient (
139+ self ._client = AsyncMongoClient (
139140 self ._connection_string ,
140141 server_api = ServerApi ("1" ),
141142 maxIdleTimeMS = 30000 ,
@@ -144,7 +145,10 @@ def _initialize_connection(self):
144145 serverSelectionTimeoutMS = 60000 ,
145146 )
146147 self ._collection = self ._client .rocketpy [self .model .NAME ]
147- logger .info ("MongoDB client initialized for %s" , self .__class__ )
148+ logger .info (
149+ "AsyncMongoClient initialized for %s" ,
150+ self .__class__ ,
151+ )
148152 except Exception as e :
149153 logger .error (
150154 f"Failed to initialize MongoDB client: { e } " , exc_info = True
You can’t perform that action at this time.
0 commit comments