Skip to content

Commit

Permalink
PYTHON-4781 Handle errors on Async PyMongo import (#1873)
Browse files Browse the repository at this point in the history
  • Loading branch information
blink1073 authored Sep 20, 2024
1 parent 0f84ad6 commit e03f8f2
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion pymongo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@

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 (
Expand All @@ -105,6 +104,14 @@
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."""

Expand Down

0 comments on commit e03f8f2

Please sign in to comment.