Skip to content

Commit f29a66b

Browse files
committed
PYTHON-4537 - Use selector asyncio loop on windows tests
1 parent afd0b6f commit f29a66b

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

test/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,12 @@
7979

8080
_IS_SYNC = True
8181

82+
# The default asyncio loop implementation on Windows
83+
# has issues with sharing sockets across loops (https://github.com/python/cpython/issues/122240)
84+
# We explicitly use a different loop implementation here to prevent that issue
85+
if sys.platform == "win32":
86+
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
87+
8288

8389
class ClientContext:
8490
client: MongoClient

test/asynchronous/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,12 @@
7979

8080
_IS_SYNC = False
8181

82+
# The default asyncio loop implementation on Windows
83+
# has issues with sharing sockets across loops (https://github.com/python/cpython/issues/122240)
84+
# We explicitly use a different loop implementation here to prevent that issue
85+
if sys.platform == "win32":
86+
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
87+
8288

8389
class AsyncClientContext:
8490
client: AsyncMongoClient

0 commit comments

Comments
 (0)