Skip to content

PYTHON-4695 Fix test event loop policy and improve error traceback for ClientBulkWriteException #1828

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 17 commits into from
Sep 6, 2024
Merged
2 changes: 2 additions & 0 deletions pymongo/_client_bulk_shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,6 @@ def _throw_client_bulk_write_exception(
"to your connection string."
)
raise OperationFailure(errmsg, code, full_result)
if isinstance(full_result["error"], BaseException):
raise ClientBulkWriteException(full_result, verbose_results) from full_result["error"]
raise ClientBulkWriteException(full_result, verbose_results)
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ addopts = ["-ra", "--strict-config", "--strict-markers", "--junitxml=xunit-resul
testpaths = ["test"]
log_cli_level = "INFO"
faulthandler_timeout = 1500
asyncio_default_fixture_loop_scope = "session"
xfail_strict = true
filterwarnings = [
"error",
Expand Down
2 changes: 2 additions & 0 deletions test/asynchronous/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ def event_loop_policy():
# has issues with sharing sockets across loops (https://github.com/python/cpython/issues/122240)
# We explicitly use a different loop implementation here to prevent that issue
if sys.platform == "win32":
# Needed for Python 3.8.
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
return asyncio.WindowsSelectorEventLoopPolicy() # type: ignore[attr-defined]

return asyncio.get_event_loop_policy()
Expand Down
2 changes: 2 additions & 0 deletions test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ def event_loop_policy():
# has issues with sharing sockets across loops (https://github.com/python/cpython/issues/122240)
# We explicitly use a different loop implementation here to prevent that issue
if sys.platform == "win32":
# Needed for Python 3.8.
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
return asyncio.WindowsSelectorEventLoopPolicy() # type: ignore[attr-defined]

return asyncio.get_event_loop_policy()
Expand Down
Loading