File tree Expand file tree Collapse file tree 4 files changed +27
-20
lines changed Expand file tree Collapse file tree 4 files changed +27
-20
lines changed Original file line number Diff line number Diff line change 79
79
80
80
_IS_SYNC = True
81
81
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 (
86
- not _IS_SYNC
87
- and sys .platform == "win32"
88
- and asyncio .get_event_loop_policy () == asyncio .WindowsProactorEventLoopPolicy
89
- ):
90
- asyncio .set_event_loop_policy (asyncio .WindowsSelectorEventLoopPolicy ()) # type: ignore[attr-defined]
91
-
92
82
93
83
class ClientContext :
94
84
client : MongoClient
Original file line number Diff line number Diff line change 79
79
80
80
_IS_SYNC = False
81
81
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 (
86
- not _IS_SYNC
87
- and sys .platform == "win32"
88
- and asyncio .get_event_loop_policy () == asyncio .WindowsProactorEventLoopPolicy
89
- ):
90
- asyncio .set_event_loop_policy (asyncio .WindowsSelectorEventLoopPolicy ()) # type: ignore[attr-defined]
91
-
92
82
93
83
class AsyncClientContext :
94
84
client : AsyncMongoClient
Original file line number Diff line number Diff line change 1
1
from __future__ import annotations
2
2
3
+ import asyncio
4
+ import sys
3
5
from test import pytest_conf
4
6
from test .asynchronous import async_setup , async_teardown
5
7
8
+ import pytest
6
9
import pytest_asyncio
7
10
8
11
_IS_SYNC = False
9
12
10
13
14
+ @pytest .fixture (scope = "session" )
15
+ def event_loop_policy ():
16
+ # The default asyncio loop implementation on Windows
17
+ # has issues with sharing sockets across loops (https://github.com/python/cpython/issues/122240)
18
+ # We explicitly use a different loop implementation here to prevent that issue
19
+ if sys .platform == "win32" :
20
+ return asyncio .WindowsSelectorEventLoopPolicy () # type: ignore[attr-defined]
21
+
22
+ return asyncio .get_event_loop_policy ()
23
+
24
+
11
25
@pytest_asyncio .fixture (scope = "session" , autouse = True )
12
26
async def test_setup_and_teardown ():
13
27
await async_setup ()
Original file line number Diff line number Diff line change 1
1
from __future__ import annotations
2
2
3
+ import asyncio
4
+ import sys
3
5
from test import pytest_conf , setup , teardown
4
6
5
7
import pytest
6
8
7
9
_IS_SYNC = True
8
10
9
11
12
+ @pytest .fixture (scope = "session" )
13
+ def event_loop_policy ():
14
+ # The default asyncio loop implementation on Windows
15
+ # has issues with sharing sockets across loops (https://github.com/python/cpython/issues/122240)
16
+ # We explicitly use a different loop implementation here to prevent that issue
17
+ if sys .platform == "win32" :
18
+ return asyncio .WindowsSelectorEventLoopPolicy () # type: ignore[attr-defined]
19
+
20
+ return asyncio .get_event_loop_policy ()
21
+
22
+
10
23
@pytest .fixture (scope = "session" , autouse = True )
11
24
def test_setup_and_teardown ():
12
25
setup ()
You can’t perform that action at this time.
0 commit comments