File tree 6 files changed +10
-29
lines changed
6 files changed +10
-29
lines changed Original file line number Diff line number Diff line change 1
1
# ruff: noqa: I001
2
2
from .asyncio import ( # noqa
3
3
asyncio_once ,
4
- get_real_current_loop ,
5
4
drain_tasks ,
6
5
draining_asyncio_tasks ,
7
6
)
Original file line number Diff line number Diff line change @@ -20,21 +20,17 @@ async def inner(*args, **kwargs):
20
20
return ta .cast (CallableT , inner )
21
21
22
22
23
- def get_real_current_loop () -> asyncio .AbstractEventLoop | None :
24
- return asyncio .get_event_loop_policy ()._local ._loop # type: ignore # noqa
25
-
26
-
27
23
def drain_tasks (loop = None ):
28
24
if loop is None :
29
- loop = get_real_current_loop ()
25
+ loop = asyncio . get_running_loop ()
30
26
31
27
while loop ._ready or loop ._scheduled : # noqa
32
28
loop ._run_once () # noqa
33
29
34
30
35
31
@contextlib .contextmanager
36
32
def draining_asyncio_tasks () -> ta .Iterator [None ]:
37
- loop = get_real_current_loop ()
33
+ loop = asyncio . get_running_loop ()
38
34
try :
39
35
yield
40
36
finally :
Original file line number Diff line number Diff line change @@ -86,7 +86,7 @@ class BridgeAwaitRequiredError(Exception):
86
86
pass
87
87
88
88
89
- class MissingBridgeGreenletError (Exception ):
89
+ class MissingBridgeThreadletError (Exception ):
90
90
pass
91
91
92
92
@@ -224,7 +224,7 @@ def s_to_a_await(awaitable: ta.Awaitable[T]) -> T:
224
224
225
225
if not getattr (g .underlying , _BRIDGE_THREADLET_ATTR , False ):
226
226
_safe_cancel_awaitable (awaitable )
227
- raise MissingBridgeGreenletError
227
+ raise MissingBridgeThreadletError
228
228
229
229
return check .not_none (g .parent ).switch (awaitable )
230
230
Original file line number Diff line number Diff line change 7
7
import trio
8
8
9
9
from ... import lang
10
- from ...diag import pydevd as pdu
11
10
from ...testing import pytest as ptu
12
11
from .. import flavors
13
12
21
20
##
22
21
23
22
24
- @pytest .fixture (autouse = True )
25
- def _patch_for_trio_asyncio_fixture ():
26
- pdu .patch_for_trio_asyncio ()
27
-
28
-
29
- ##
30
-
31
-
32
23
@flavors .mark_anyio
33
24
async def _anyio_func (call_asyncio , call_trio ):
34
25
await anyio .sleep (0 )
Original file line number Diff line number Diff line change @@ -36,7 +36,7 @@ def f():
36
36
37
37
38
38
@ptu .skip .if_cant_import ('greenlet' )
39
- def test_bridge (event_loop ):
39
+ def test_bridge ():
40
40
import greenlet
41
41
42
42
l = []
@@ -69,4 +69,5 @@ async def main():
69
69
)
70
70
assert rs == [4 , 4 ]
71
71
72
- event_loop .run_until_complete (main ()) # noqa
72
+ with asyncio .Runner () as runner :
73
+ runner .get_loop ().run_until_complete (main ()) # noqa
Original file line number Diff line number Diff line change 15
15
import trio
16
16
17
17
from ... import lang
18
- from ...diag import pydevd as pdu
19
18
from ...testing import pytest as ptu
20
- from ..asyncio import all as asu
21
19
22
20
23
21
if ta .TYPE_CHECKING :
26
24
trai = lang .proxy_import ('trio_asyncio' )
27
25
28
26
29
- @pytest .fixture (autouse = True )
30
- def _patch_for_trio_asyncio_fixture ():
31
- pdu .patch_for_trio_asyncio ()
32
-
33
-
34
27
@ptu .skip .if_cant_import ('trio_asyncio' )
35
28
def test_hybrid ():
36
29
async def hybrid ():
@@ -179,7 +172,7 @@ async def test_all_asyncs(__async_backend): # noqa
179
172
match __async_backend :
180
173
case 'asyncio' :
181
174
assert backend == 'asyncio'
182
- assert asu . get_real_current_loop () is not None
175
+ assert asyncio . get_running_loop () is not None
183
176
assert trai .current_loop .get () is None
184
177
assert not isinstance (asyncio .get_running_loop (), trai .TrioEventLoop )
185
178
@@ -189,7 +182,8 @@ async def test_all_asyncs(__async_backend): # noqa
189
182
190
183
case 'trio' :
191
184
assert backend == 'trio'
192
- assert asu .get_real_current_loop () is None
185
+ with pytest .raises (RuntimeError ):
186
+ assert asyncio .get_running_loop ()
193
187
assert trai .current_loop .get () is None
194
188
195
189
with pytest .raises (RuntimeError ):
You can’t perform that action at this time.
0 commit comments