PYTHON-4781 Handle errors on Async PyMongo import (#1873)

This commit is contained in:
Steven Silvester 2024-09-20 16:50:59 -05:00 committed by GitHub
parent 0f84ad6ed9
commit e03f8f24f2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -88,7 +88,6 @@ TEXT = "text"
from pymongo import _csot
from pymongo._version import __version__, get_version_string, version_tuple
from pymongo.asynchronous.mongo_client import AsyncMongoClient
from pymongo.common import MAX_SUPPORTED_WIRE_VERSION, MIN_SUPPORTED_WIRE_VERSION
from pymongo.cursor import CursorType
from pymongo.operations import (
@ -105,6 +104,14 @@ from pymongo.synchronous.collection import ReturnDocument
from pymongo.synchronous.mongo_client import MongoClient
from pymongo.write_concern import WriteConcern
try:
from pymongo.asynchronous.mongo_client import AsyncMongoClient
except Exception as e:
# PYTHON-4781: Importing asyncio can fail on Windows.
import warnings as _warnings
_warnings.warn(f"Failed to import Async PyMongo: {e!r}", ImportWarning, stacklevel=2)
version = __version__
"""Current version of PyMongo."""