raise InvalidOperation("Cannot use MongoClient after close") pymongo.errors.InvalidOperation: Cannot use MongoClient after close I am getting this error while logging from a FastAPI python client with async operation.